Skip to main content

Url

Struct Url 

Source
pub struct Url<'a> { /* private fields */ }
Expand description

A URL split by PHP’s parse_url (php_url_parse_ex2 in ext/standard/url.c).

Components borrow from the input. PHP replaces ASCII control characters (iscntrl: 0x00–0x1F and 0x7F) in every component with _; the accessors do the same, allocating only when a component contains one. Components are byte strings because PHP strings are: when the input is valid UTF-8, so is every component (the parser only splits at ASCII bytes).

Implementations§

Source§

impl<'a> Url<'a>

Source

pub fn scheme(&self) -> Option<Cow<'a, [u8]>>

scheme

Source

pub fn host(&self) -> Option<Cow<'a, [u8]>>

host

Source

pub fn port(&self) -> Option<u16>

port. PHP reports a port only when one was written (:0 included).

Source

pub fn user(&self) -> Option<Cow<'a, [u8]>>

user

Source

pub fn pass(&self) -> Option<Cow<'a, [u8]>>

pass

Source

pub fn path(&self) -> Option<Cow<'a, [u8]>>

path

Source

pub fn query(&self) -> Option<Cow<'a, [u8]>>

query (without ?)

Source

pub fn fragment(&self) -> Option<Cow<'a, [u8]>>

fragment (without #)

Source

pub fn component(&self, component: Component) -> Option<ComponentValue<'a>>

parse_url($url, $component) for a URL that parsed: None is PHP’s null (component absent).

Trait Implementations§

Source§

impl<'a> Clone for Url<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Url<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for Url<'a>

Source§

impl<'a> PartialEq for Url<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Url<'a>

Auto Trait Implementations§

§

impl<'a> Forget for Url<'a>

§

impl<'a> Freeze for Url<'a>

§

impl<'a> Move for Url<'a>

§

impl<'a> RefUnwindSafe for Url<'a>

§

impl<'a> Send for Url<'a>

§

impl<'a> Sync for Url<'a>

§

impl<'a> Unpin for Url<'a>

§

impl<'a> UnsafeUnpin for Url<'a>

§

impl<'a> UnwindSafe for Url<'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, dest: *mut u8)

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.