pub struct ParseOptions<'a> { /* private fields */ }
Expand description
Full configuration for the URL parser.
Implementations§
Source§impl<'a> ParseOptions<'a>
impl<'a> ParseOptions<'a>
Sourcepub fn base_url(self, new: Option<&'a Url>) -> Self
pub fn base_url(self, new: Option<&'a Url>) -> Self
Change the base URL
See the notes of Url::join
for more details about how this base is considered
when parsing.
Sourcepub fn encoding_override(self, new: EncodingOverride<'a>) -> Self
pub fn encoding_override(self, new: EncodingOverride<'a>) -> Self
Override the character encoding of query strings. This is a legacy concept only relevant for HTML.
Sourcepub fn syntax_violation_callback(
self,
new: Option<&'a dyn Fn(SyntaxViolation)>,
) -> Self
pub fn syntax_violation_callback( self, new: Option<&'a dyn Fn(SyntaxViolation)>, ) -> Self
Call the provided function or closure for a non-fatal SyntaxViolation
when it occurs during parsing. Note that since the provided function is
Fn
, the caller might need to utilize interior mutability, such as with
a RefCell
, to collect the violations.
§Example
use std::cell::RefCell;
use url::{Url, SyntaxViolation};
let violations = RefCell::new(Vec::new());
let url = Url::options()
.syntax_violation_callback(Some(&|v| violations.borrow_mut().push(v)))
.parse("https:////example.com")?;
assert_eq!(url.as_str(), "https://example.com/");
assert_eq!(violations.into_inner(),
vec!(SyntaxViolation::ExpectedDoubleSlash));
Trait Implementations§
Source§impl<'a> Clone for ParseOptions<'a>
impl<'a> Clone for ParseOptions<'a>
Source§fn clone(&self) -> ParseOptions<'a>
fn clone(&self) -> ParseOptions<'a>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreimpl<'a> Copy for ParseOptions<'a>
Auto Trait Implementations§
impl<'a> Freeze for ParseOptions<'a>
impl<'a> !RefUnwindSafe for ParseOptions<'a>
impl<'a> !Send for ParseOptions<'a>
impl<'a> !Sync for ParseOptions<'a>
impl<'a> Unpin for ParseOptions<'a>
impl<'a> !UnwindSafe for ParseOptions<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more