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>) -> ParseOptions<'a>
pub fn base_url(self, new: Option<&'a Url>) -> ParseOptions<'a>
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: Option<&'a dyn Fn(&str) -> Cow<'_, [u8]>>,
) -> ParseOptions<'a>
pub fn encoding_override( self, new: Option<&'a dyn Fn(&str) -> Cow<'_, [u8]>>, ) -> ParseOptions<'a>
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)>,
) -> ParseOptions<'a>
pub fn syntax_violation_callback( self, new: Option<&'a dyn Fn(SyntaxViolation)>, ) -> ParseOptions<'a>
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