url

Struct ParseOptions

source
pub struct ParseOptions<'a> { /* private fields */ }
Expand description

Full configuration for the URL parser.

Implementations§

source§

impl<'a> ParseOptions<'a>

source

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.

source

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.

source

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));
source

pub fn parse(self, input: &str) -> Result<Url, ParseError>

Parse an URL string with the configuration so far.

Trait Implementations§

source§

impl<'a> Clone for ParseOptions<'a>

source§

fn clone(&self) -> ParseOptions<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.