[][src]Struct iref::IriRef

pub struct IriRef<'a> { /* fields omitted */ }

IRI-reference slice.

Wrapper around a borrowed bytes slice representing an IRI-reference. An IRI-reference can be seen as an Iri with an optional Scheme. IRI-references are resolved against a base IRI into a proper IRI using the Reference Resolution Algorithm provided by the resolved method.

Example

let base_iri = Iri::new("http://a/b/c/d;p?q")?;
let mut iri_ref = IriRefBuf::new("g;x=1/../y")?;

assert_eq!(iri_ref.resolved(base_iri), "http://a/b/c/y");

Methods

impl<'a> IriRef<'a>[src]

pub fn new<S: AsRef<[u8]> + ?Sized>(buffer: &'a S) -> Result<IriRef<'a>, Error>[src]

Create a new IRI-reference slice from a bytes slice.

This may fail if the source slice is not UTF-8 encoded, or if is not a valid IRI-reference.

pub fn parsing_data(&self) -> ParsedIriRef[src]

Get the underlying parsing data.

pub const unsafe fn from_raw(data: &'a [u8], p: ParsedIriRef) -> IriRef<'a>[src]

Build an IRI reference from a slice and parsing data.

This is unsafe since the input slice is not checked against the given parsing data.

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 into_iri(self) -> Result<Iri<'a>, IriRef<'a>>[src]

Convert the IRI-reference into an IRI, if possible.

An IRI-reference is a valid IRI only if it has a defined Scheme.

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 IriRef<'a>[src]

impl<'a> Copy for IriRef<'a>[src]

impl<'a> Debug for IriRef<'a>[src]

impl<'a> Display for IriRef<'a>[src]

impl<'a> Eq for IriRef<'a>[src]

impl<'a> From<&'a IriBuf> for IriRef<'a>[src]

impl<'a> From<&'a IriRef<'a>> for IriRefBuf[src]

impl<'a> From<&'a IriRefBuf> for IriRef<'a>[src]

impl<'a> From<Iri<'a>> for IriRef<'a>[src]

impl<'a> From<IriRef<'a>> for IriRefBuf[src]

impl<'a> Hash for IriRef<'a>[src]

impl<'a> Ord for IriRef<'a>[src]

impl<'a> PartialEq<&'a str> for IriRef<'a>[src]

impl<'a> PartialEq<Iri<'a>> for IriRef<'a>[src]

impl<'a> PartialEq<IriBuf> for IriRef<'a>[src]

impl<'a> PartialEq<IriRef<'a>> for IriBuf[src]

impl<'a> PartialEq<IriRef<'a>> for Iri<'a>[src]

impl<'a> PartialEq<IriRef<'a>> for IriRefBuf[src]

impl<'a> PartialEq<IriRef<'a>> for IriRef<'a>[src]

impl<'a> PartialEq<IriRefBuf> for IriRef<'a>[src]

impl<'a> PartialOrd<Iri<'a>> for IriRef<'a>[src]

impl<'a> PartialOrd<IriBuf> for IriRef<'a>[src]

impl<'a> PartialOrd<IriRef<'a>> for IriBuf[src]

impl<'a> PartialOrd<IriRef<'a>> for Iri<'a>[src]

impl<'a> PartialOrd<IriRef<'a>> for IriRefBuf[src]

impl<'a> PartialOrd<IriRef<'a>> for IriRef<'a>[src]

impl<'a> PartialOrd<IriRefBuf> for IriRef<'a>[src]

impl<'a> TryFrom<IriRef<'a>> for IriBuf[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<IriRef<'a>> for Iri<'a>[src]

type Error = IriRef<'a>

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<'a> RefUnwindSafe for IriRef<'a>

impl<'a> Send for IriRef<'a>

impl<'a> Sync for IriRef<'a>

impl<'a> Unpin for IriRef<'a>

impl<'a> UnwindSafe for IriRef<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.