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§
source§impl 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§
source§impl Ord for IRI
impl Ord for IRI
source§impl PartialOrd<IRI> for IRI
impl PartialOrd<IRI> for IRI
1.0.0 · source§fn 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 more