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>
pub fn new<I>(iri: I) -> Result<Self, InvalidIRIScheme>
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<'de> Deserialize<'de> for IRI
impl<'de> Deserialize<'de> for IRI
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for IRI
impl Ord for IRI
Source§impl PartialOrd for IRI
impl PartialOrd for IRI
impl Eq for IRI
impl StructuralPartialEq for IRI
Auto Trait Implementations§
impl Freeze for IRI
impl RefUnwindSafe for IRI
impl Send for IRI
impl Sync for IRI
impl Unpin for IRI
impl UnwindSafe for IRI
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