Struct url::ParseOptions
source · 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 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