pub struct IRI { /* private fields */ }
Expand description
A minimal IRI (International Resource Identifier) implementation which just parses the scheme but no scheme specific part (and neither fragments wrt. those definitions in which fragments are not scheme specific parts).
This implementation does not perform any form of normalization or other IRI specific aspects, it’s basically just a String split into two parts.
Additionally this implementations requires all URI to be valid utf8.
Example
let uri = IRI::new("file:/random/logo.png").unwrap();
assert_eq!(uri.scheme(), "file");
assert_eq!(uri.tail(), "/random/logo.png");
Implementations
sourceimpl IRI
impl IRI
sourcepub fn from_parts(scheme: &str, tail: &str) -> Result<IRI, InvalidIRIScheme>
pub fn from_parts(scheme: &str, tail: &str) -> Result<IRI, InvalidIRIScheme>
Create a new IRI from a scheme part and a tail part.
This will convert the scheme part into lower case before using it.
sourcepub fn new<I>(iri: I) -> Result<IRI, InvalidIRIScheme>where
I: Into<String>,
pub fn new<I>(iri: I) -> Result<IRI, InvalidIRIScheme>where
I: Into<String>,
crates a new a IRI
- this determines the first occurrence of
:
to split the input into scheme and tail - it validates that the scheme name is RFC 3986
compatible, i.e. is ascii, starting with a letter followed by alpha numeric characters
(or
"+"
,"-"
,"."
). - converts the scheme part to lower case
sourcepub fn with_tail(&self, new_tail: &str) -> IRI
pub fn with_tail(&self, new_tail: &str) -> IRI
Creates a new IRI with the same schema but a different tail.
sourcepub fn scheme(&self) -> &str
pub fn scheme(&self) -> &str
The scheme part of the uri excluding the :
seperator.
The scheme is guaranteed to be lower case.
Example
let uri = IRI::new("file:///opt/share/logo.png").unwrap();
assert_eq!(uri.scheme(), "file");
Trait Implementations
sourceimpl<'de> Deserialize<'de> for IRI
impl<'de> Deserialize<'de> for IRI
sourcefn deserialize<D>(
deserializer: D
) -> Result<IRI, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<IRI, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for IRI
impl Ord for IRI
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<IRI> for IRI
impl PartialOrd<IRI> for IRI
sourcefn partial_cmp(&self, other: &IRI) -> Option<Ordering>
fn partial_cmp(&self, other: &IRI) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl PathRebaseable for IRI
impl PathRebaseable for IRI
sourcefn rebase_to_include_base_dir(
&mut self,
base_dir: impl AsRef<Path>
) -> Result<(), UnsupportedPathError>
fn rebase_to_include_base_dir(
&mut self,
base_dir: impl AsRef<Path>
) -> Result<(), UnsupportedPathError>
Prefixes path in the type with
base_dir
. Read moresourcefn rebase_to_exclude_base_dir(
&mut self,
base_dir: impl AsRef<Path>
) -> Result<(), UnsupportedPathError>
fn rebase_to_exclude_base_dir(
&mut self,
base_dir: impl AsRef<Path>
) -> Result<(), UnsupportedPathError>
Removes the
base_dir
prefix. Read moresourceimpl Serialize for IRI
impl Serialize for IRI
sourcefn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for IRI
impl StructuralEq for IRI
impl StructuralPartialEq for IRI
Auto Trait Implementations
impl RefUnwindSafe for IRI
impl Send for IRI
impl Sync for IRI
impl Unpin for IRI
impl UnwindSafe for IRI
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more