[][src]Struct iri_string::types::IriString

pub struct IriString(_);

An owned string of an absolute IRI possibly with fragment part.

This corresponds to IRI rule in RFC 3987. This is scheme ":" ihier-part [ "?" iquery ] [ "#" ifragment ]. In other words, this is AbsoluteIriString with fragment part allowed.

See documentation for IriStr.

Methods

impl IriString[src]

pub fn into_absolute_and_fragment(
    self
) -> (AbsoluteIriString, Option<IriFragmentString>)
[src]

Splits the IRI into absolute IRI part and fragment part.

A leading # character is truncated if the fragment part exists.

Examples

use std::convert::TryFrom;
let iri = "foo://bar/baz?qux=quux#corge".parse::<IriString>()?;
let (absolute, fragment) = iri.into_absolute_and_fragment();
let fragment_expected = IriFragmentString::try_from("corge".to_owned())?;
assert_eq!(absolute, "foo://bar/baz?qux=quux");
assert_eq!(fragment, Some(fragment_expected));
use std::convert::TryFrom;
let iri = "foo://bar/baz?qux=quux#".parse::<IriString>()?;
let (absolute, fragment) = iri.into_absolute_and_fragment();
let fragment_expected = IriFragmentString::try_from("".to_owned())?;
assert_eq!(absolute, "foo://bar/baz?qux=quux");
assert_eq!(fragment, Some(fragment_expected));
use std::convert::TryFrom;
let iri = "foo://bar/baz?qux=quux".parse::<IriString>()?;
let (absolute, fragment) = iri.into_absolute_and_fragment();
assert_eq!(absolute, "foo://bar/baz?qux=quux");
assert_eq!(fragment, None);

pub fn into_absolute(self) -> AbsoluteIriString[src]

Strips the fragment part if exists, and returns AbsoluteIriString.

Examples

let iri = "foo://bar/baz?qux=quux#corge".parse::<IriString>()?;
assert_eq!(iri.into_absolute(), "foo://bar/baz?qux=quux");
let iri = "foo://bar/baz?qux=quux".parse::<IriString>()?;
assert_eq!(iri.into_absolute(), "foo://bar/baz?qux=quux");

pub fn set_fragment(&mut self, fragment: Option<&IriFragmentStr>)[src]

Sets the fragment part to the given string.

Removes fragment part (and following # character) if None is given.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the capacity of the inner buffer to match its length.

Methods from Deref<Target = IriStr>

pub fn to_absolute_and_fragment(
    &self
) -> (&AbsoluteIriStr, Option<&IriFragmentStr>)
[src]

Splits the IRI into absolute IRI part and fragment part.

A leading # character is truncated if the fragment part exists.

Examples

let iri = IriStr::new("foo://bar/baz?qux=quux#corge")?;
let (absolute, fragment) = iri.to_absolute_and_fragment();
let fragment_expected = IriFragmentStr::new("corge")?;
assert_eq!(absolute, "foo://bar/baz?qux=quux");
assert_eq!(fragment, Some(fragment_expected));
let iri = IriStr::new("foo://bar/baz?qux=quux#")?;
let (absolute, fragment) = iri.to_absolute_and_fragment();
let fragment_expected = IriFragmentStr::new("")?;
assert_eq!(absolute, "foo://bar/baz?qux=quux");
assert_eq!(fragment, Some(fragment_expected));
let iri = IriStr::new("foo://bar/baz?qux=quux")?;
let (absolute, fragment) = iri.to_absolute_and_fragment();
assert_eq!(absolute, "foo://bar/baz?qux=quux");
assert_eq!(fragment, None);

pub fn to_absolute(&self) -> &AbsoluteIriStr[src]

Strips the fragment part if exists, and returns &AbsoluteIriStr.

Examples

let iri = IriStr::new("foo://bar/baz?qux=quux#corge")?;
assert_eq!(iri.to_absolute(), "foo://bar/baz?qux=quux");
let iri = IriStr::new("foo://bar/baz?qux=quux")?;
assert_eq!(iri.to_absolute(), "foo://bar/baz?qux=quux");

pub fn as_str(&self) -> &str[src]

Returns &str.

Trait Implementations

impl AsRef<str> for IriString where
    str: AsRef<str>, 

impl AsRef<IriStr> for IriString

impl AsRef<IriReferenceStr> for IriString[src]

impl From<AbsoluteIriString> for IriString[src]

impl From<IriString> for String

impl From<IriString> for IriReferenceString[src]

impl Clone for IriString[src]

impl Eq for IriString[src]

impl Ord for IriString[src]

impl PartialEq<IriString> for AbsoluteIriStr[src]

impl PartialEq<AbsoluteIriStr> for IriString[src]

impl<'_> PartialEq<IriString> for &'_ AbsoluteIriStr[src]

impl<'_> PartialEq<&'_ AbsoluteIriStr> for IriString[src]

impl PartialEq<IriString> for IriString[src]

impl PartialEq<IriStr> for IriString

impl PartialEq<IriString> for IriStr

impl<'_> PartialEq<&'_ IriStr> for IriString

impl<'_> PartialEq<IriString> for &'_ IriStr

impl<'_> PartialEq<Cow<'_, IriStr>> for IriString

impl<'_> PartialEq<IriString> for Cow<'_, IriStr>

impl PartialEq<str> for IriString

impl PartialEq<IriString> for str

impl<'_> PartialEq<&'_ str> for IriString

impl<'_> PartialEq<IriString> for &'_ str

impl<'_> PartialEq<Cow<'_, str>> for IriString

impl<'_> PartialEq<IriString> for Cow<'_, str>

impl PartialEq<IriReferenceStr> for IriString[src]

impl PartialEq<IriString> for IriReferenceStr[src]

impl<'_> PartialEq<&'_ IriReferenceStr> for IriString[src]

impl<'_> PartialEq<IriString> for &'_ IriReferenceStr[src]

impl<'_> PartialEq<Cow<'_, IriReferenceStr>> for IriString[src]

impl<'_> PartialEq<IriString> for Cow<'_, IriReferenceStr>[src]

impl PartialOrd<IriString> for AbsoluteIriStr[src]

impl PartialOrd<AbsoluteIriStr> for IriString[src]

impl<'_> PartialOrd<IriString> for &'_ AbsoluteIriStr[src]

impl<'_> PartialOrd<&'_ AbsoluteIriStr> for IriString[src]

impl PartialOrd<IriString> for IriString[src]

impl PartialOrd<IriStr> for IriString

impl PartialOrd<IriString> for IriStr

impl<'_> PartialOrd<&'_ IriStr> for IriString

impl<'_> PartialOrd<IriString> for &'_ IriStr

impl<'_> PartialOrd<Cow<'_, IriStr>> for IriString

impl<'_> PartialOrd<IriString> for Cow<'_, IriStr>

impl PartialOrd<str> for IriString

impl PartialOrd<IriString> for str

impl<'_> PartialOrd<&'_ str> for IriString

impl<'_> PartialOrd<IriString> for &'_ str

impl<'_> PartialOrd<Cow<'_, str>> for IriString

impl<'_> PartialOrd<IriString> for Cow<'_, str>

impl PartialOrd<IriReferenceStr> for IriString[src]

impl PartialOrd<IriString> for IriReferenceStr[src]

impl<'_> PartialOrd<&'_ IriReferenceStr> for IriString[src]

impl<'_> PartialOrd<IriString> for &'_ IriReferenceStr[src]

impl<'_> PartialOrd<Cow<'_, IriReferenceStr>> for IriString[src]

impl<'_> PartialOrd<IriString> for Cow<'_, IriReferenceStr>[src]

impl Display for IriString where
    IriStr: Display

impl Debug for IriString[src]

impl TryFrom<IriString> for AbsoluteIriString[src]

type Error = IriCreationError<String>

The type returned in the event of a conversion error.

impl TryFrom<String> for IriString

type Error = IriCreationError<String>

The type returned in the event of a conversion error.

impl TryFrom<IriReferenceString> for IriString[src]

type Error = IriCreationError<String>

The type returned in the event of a conversion error.

impl FromStr for IriString

type Err = Error

The associated error which can be returned from parsing.

impl Deref for IriString

type Target = IriStr

The resulting type after dereferencing.

impl Hash for IriString[src]

impl StructuralPartialEq for IriString[src]

impl StructuralEq for IriString[src]

impl Borrow<str> for IriString where
    str: Borrow<str>, 

impl Borrow<IriStr> for IriString

impl Serialize for IriString[src]

impl<'de> Deserialize<'de> for IriString[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T> From<T> for 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.

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

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

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

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]