pub struct Url<'a> { /* private fields */ }Expand description
A parsed URL record backed by its WHATWG serialization (href).
Component boundaries are u32 byte offsets into Self::as_str.
Absent optional markers use the sentinel Url::NONE (u32::MAX).
When the input is already in canonical form, Backing::Borrowed avoids
heap allocation entirely.
Implementations§
Source§impl<'a> Url<'a>
impl<'a> Url<'a>
Sourcepub fn into_owned(self) -> Url<'static>
pub fn into_owned(self) -> Url<'static>
Detach from the input lifetime by owning the serialization.
Sourcepub fn parse(input: &'a str) -> Result<Self, ParseError>
pub fn parse(input: &'a str) -> Result<Self, ParseError>
Parse input according to the WHATWG basic URL parser with no base URL.
§Errors
Returns ParseError::Failure on WHATWG failure, or
ParseError::InputTooLong when the input cannot be indexed by u32.
Sourcepub fn parse_with_base(
input: &'a str,
base: Option<&Url<'_>>,
) -> Result<Self, ParseError>
pub fn parse_with_base( input: &'a str, base: Option<&Url<'_>>, ) -> Result<Self, ParseError>
pub const fn scheme_range(&self) -> Range<usize>
pub fn has_host(&self) -> bool
pub const fn port_u16(&self) -> Option<u16>
Sourcepub fn host_with_port(&self) -> &str
pub fn host_with_port(&self) -> &str
WHATWG / WPT host getter: hostname, plus ":" port when port is non-null.
Sourcepub fn pathname(&self) -> &str
pub fn pathname(&self) -> &str
Alias for Self::path matching the WPT pathname attribute.
Sourcepub fn percent_decode(raw: &str) -> Cow<'_, str>
pub fn percent_decode(raw: &str) -> Cow<'_, str>
Percent-decode raw, allocating only when decoding changes the bytes.
Trait Implementations§
impl Eq for Url<'_>
Auto Trait Implementations§
impl<'a> Freeze 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> 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