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>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 40 bytes