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<Self, InvalidIRIScheme>
pub fn from_parts(scheme: &str, tail: &str) -> Result<Self, 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<Self, InvalidIRIScheme>where
I: Into<String>,
pub fn new<I>(iri: I) -> Result<Self, 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) -> Self
pub fn with_tail(&self, new_tail: &str) -> Self
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 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 moreimpl 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