[−][src]Struct iref::Iri
IRI slice.
Wrapper around a borrowed bytes slice representing an IRI.
An IRI can be seen as an IRI-reference with a defined Scheme
.
All methods of IriRef
are available from this type, however the scheme
method
is redefined to always return some scheme.
Example
let iri = Iri::new("https://www.rust-lang.org/foo/bar?query#frag")?; println!("scheme: {}", iri.scheme()); // note the absence of `unwrap` here since // the scheme is always defined in an IRI. println!("authority: {}", iri.authority().unwrap()); println!("path: {}", iri.path()); println!("query: {}", iri.query().unwrap()); println!("fragment: {}", iri.fragment().unwrap());
Methods
impl<'a> Iri<'a>
[src]
pub fn new<S: AsRef<[u8]> + ?Sized>(buffer: &'a S) -> Result<Iri<'a>, Error>
[src]
Create a new IRI slice from a bytes slice.
This may fail if the source slice is not UTF-8 encoded, or is not a valid IRI.
pub fn as_iri_ref(&self) -> IriRef<'a>
[src]
Get an IriRef
out of this IRI.
An IRI is always a valid IRI-reference.
pub fn scheme(&self) -> Scheme
[src]
Get the scheme of the IRI.
Contrarily to IriRef
, the scheme of an IRI is always defined.
Methods from Deref<Target = IriRef<'a>>
pub fn len(&self) -> usize
[src]
Get the length is the IRI-reference, in bytes.
pub fn as_ref(&self) -> &[u8]
[src]
Get a reference to the underlying bytes slice representing the IRI-reference.
pub fn as_str(&self) -> &str
[src]
Get the IRI-reference as a string slice.
pub fn as_pct_str(&self) -> &PctStr
[src]
Get the IRI-reference as a percent-encoded string slice.
pub fn scheme(&self) -> Option<Scheme>
[src]
Get the scheme of the IRI-reference.
The scheme is located at the very begining of the IRI-reference and delimited by an ending
:
.
Example
assert_eq!(IriRef::new("foo://example.com:8042").unwrap().scheme().unwrap(), "foo"); assert_eq!(IriRef::new("//example.com:8042").unwrap().scheme(), None);
pub fn authority(&self) -> Option<Authority>
[src]
Get the authority of the IRI-reference.
The authority is delimited by the //
string, after the scheme.
Example
assert_eq!(IriRef::new("foo://example.com:8042").unwrap().authority().unwrap().host(), "example.com"); assert_eq!(IriRef::new("foo:").unwrap().authority(), None);
pub fn path(&'a self) -> Path<'a>
[src]
Get the path of the IRI-reference.
The path is located just after the authority. It is always defined, even if empty.
Example
assert_eq!(IriRef::new("foo:/a/b/c?query").unwrap().path(), "/a/b/c"); assert!(IriRef::new("foo:#fragment").unwrap().path().is_empty());
pub fn query(&self) -> Option<Query>
[src]
Get the query of the IRI-reference.
The query part is delimited by the ?
character after the path.
Example
assert_eq!(IriRef::new("//example.org?query").unwrap().query().unwrap(), "query"); assert!(IriRef::new("//example.org/foo/bar#fragment").unwrap().query().is_none());
pub fn fragment(&self) -> Option<Fragment>
[src]
Get the fragment of the IRI-reference.
The fragment part is delimited by the #
character after the query.
Example
assert_eq!(IriRef::new("//example.org#foo").unwrap().fragment().unwrap(), "foo"); assert!(IriRef::new("//example.org").unwrap().fragment().is_none());
pub fn resolved<'b, Base: Into<Iri<'b>>>(&self, base_iri: Base) -> IriBuf
[src]
Resolve the IRI reference against the given base IRI.
Return the resolved IRI.
See the IriRefBuf::resolve
method for more informations about the resolution process.
Trait Implementations
impl<'a> Clone for Iri<'a>
[src]
impl<'a> Copy for Iri<'a>
[src]
impl<'a> Debug for Iri<'a>
[src]
impl<'a> Deref for Iri<'a>
[src]
impl<'a> Display for Iri<'a>
[src]
impl<'a> Eq for Iri<'a>
[src]
impl<'a> From<&'a Iri<'a>> for IriBuf
[src]
impl<'a> From<&'a Iri<'a>> for IriRefBuf
[src]
impl<'a> From<&'a IriBuf> for Iri<'a>
[src]
impl<'a> From<Iri<'a>> for IriBuf
[src]
impl<'a> From<Iri<'a>> for IriRefBuf
[src]
impl<'a> From<Iri<'a>> for IriRef<'a>
[src]
impl<'a> Hash for Iri<'a>
[src]
fn hash<H: Hasher>(&self, hasher: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a> Ord for Iri<'a>
[src]
fn cmp(&self, other: &Iri<'a>) -> Ordering
[src]
#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'a> PartialEq<&'a str> for Iri<'a>
[src]
impl<'a> PartialEq<Iri<'a>> for IriBuf
[src]
impl<'a> PartialEq<Iri<'a>> for Iri<'a>
[src]
impl<'a> PartialEq<Iri<'a>> for IriRefBuf
[src]
impl<'a> PartialEq<Iri<'a>> for IriRef<'a>
[src]
impl<'a> PartialEq<IriBuf> for Iri<'a>
[src]
impl<'a> PartialEq<IriRef<'a>> for Iri<'a>
[src]
fn eq(&self, other: &IriRef<'a>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialEq<IriRefBuf> for Iri<'a>
[src]
impl<'a> PartialOrd<Iri<'a>> for IriBuf
[src]
fn partial_cmp(&self, other: &Iri<'a>) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialOrd<Iri<'a>> for Iri<'a>
[src]
fn partial_cmp(&self, other: &Iri<'a>) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialOrd<Iri<'a>> for IriRefBuf
[src]
fn partial_cmp(&self, other: &Iri<'a>) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialOrd<Iri<'a>> for IriRef<'a>
[src]
fn partial_cmp(&self, other: &Iri<'a>) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialOrd<IriBuf> for Iri<'a>
[src]
fn partial_cmp(&self, other: &IriBuf) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialOrd<IriRef<'a>> for Iri<'a>
[src]
fn partial_cmp(&self, other: &IriRef<'a>) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialOrd<IriRefBuf> for Iri<'a>
[src]
fn partial_cmp(&self, other: &IriRefBuf) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> TryFrom<&'a IriRefBuf> for Iri<'a>
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(buffer: &'a IriRefBuf) -> Result<Iri<'a>, Error>
[src]
impl<'a> TryFrom<IriRef<'a>> for Iri<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Iri<'a>
impl<'a> Send for Iri<'a>
impl<'a> Sync for Iri<'a>
impl<'a> Unpin for Iri<'a>
impl<'a> UnwindSafe for Iri<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,