[][src]Struct iri_string::types::RiString

pub struct RiString<S> { /* fields omitted */ }

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

This corresponds to IRI rule in RFC 3987 (and URI rule in RFC 3986). The rule for IRI is scheme ":" ihier-part [ "?" iquery ] [ "#" ifragment ]. In other words, this is RiAbsoluteString with fragment part allowed.

For details, see the document for RiStr.

Enabled by alloc or std feature.

Methods

impl<S: Spec> RiString<S>[src]

pub fn shrink_to_fit(&mut self)[src]

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

impl<S: Spec> RiString<S>[src]

pub fn into_absolute_and_fragment(
    self
) -> (RiAbsoluteString<S>, Option<RiFragmentString<S>>)
[src]

Splits the IRI into an absolute IRI part and a 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())
    .map_err(|e| e.validation_error())?;
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())
    .map_err(|e| e.validation_error())?;
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) -> RiAbsoluteString<S>[src]

Strips the fragment part if exists, and returns an RiAbsoluteString.

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<&RiFragmentStr<S>>)[src]

Sets the fragment part to the given string.

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

Methods from Deref<Target = RiStr<S>>

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

Returns &str.

pub fn len(&self) -> usize[src]

Returns the string length.

pub fn is_empty(&self) -> bool[src]

Returns whether the string is empty.

pub fn to_absolute_and_fragment(
    &self
) -> (&RiAbsoluteStr<S>, Option<&RiFragmentStr<S>>)
[src]

Splits the IRI into an absolute IRI part and a fragment part.

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

Examples

If the IRI has a fragment part, Some(_) is returned.

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));

When the fragment part exists but is empty string, Some(_) is returned.

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));

If the IRI has no fragment, None is returned.

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) -> &RiAbsoluteStr<S>[src]

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

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 fragment(&self) -> Option<&RiFragmentStr<S>>[src]

Returns the fragment part if exists.

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

Examples

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

Trait Implementations

impl<S: Spec> AsRef<RiReferenceStr<S>> for RiString<S>[src]

impl AsRef<RiStr<IriSpec>> for RiString<UriSpec>[src]

impl<S: Spec> AsRef<RiStr<S>> for RiString<S>[src]

impl<S: Spec> AsRef<str> for RiString<S>[src]

impl<S: Spec> Borrow<RiStr<S>> for RiString<S>[src]

impl<S: Spec> Borrow<str> for RiString<S>[src]

impl<S: Spec> Clone for RiString<S>[src]

impl<S: Spec> Debug for RiString<S>[src]

impl<S: Spec> Deref for RiString<S>[src]

type Target = RiStr<S>

The resulting type after dereferencing.

impl<'de, S: Spec> Deserialize<'de> for RiString<S>[src]

impl<S: Spec> Display for RiString<S>[src]

impl<S: Spec> Eq for RiString<S>[src]

impl<'_, S: Spec> From<&'_ RiStr<S>> for RiString<S>[src]

impl<S: Spec> From<RiAbsoluteString<S>> for RiString<S>[src]

impl<S: Spec> From<RiString<S>> for String[src]

impl<S: Spec> From<RiString<S>> for RiReferenceString<S>[src]

impl<S: Spec> FromStr for RiString<S>[src]

type Err = Error

The associated error which can be returned from parsing.

impl<S: Spec> Hash for RiString<S>[src]

impl<S: Spec> Ord for RiString<S>[src]

impl<'_, S: Spec, T: Spec> PartialEq<&'_ RiAbsoluteStr<S>> for RiString<T>[src]

impl<'_, S: Spec, T: Spec> PartialEq<&'_ RiReferenceStr<T>> for RiString<S>[src]

impl<'_, S: Spec, T: Spec> PartialEq<&'_ RiStr<S>> for RiString<T>[src]

impl<'_, S: Spec> PartialEq<&'_ str> for RiString<S>[src]

impl<'_, S: Spec, T: Spec> PartialEq<Cow<'_, RiAbsoluteStr<S>>> for RiString<T>[src]

impl<'_, S: Spec, T: Spec> PartialEq<Cow<'_, RiReferenceStr<T>>> for RiString<S>[src]

impl<'_, S: Spec, T: Spec> PartialEq<Cow<'_, RiStr<S>>> for RiString<T>[src]

impl<'_, S: Spec> PartialEq<Cow<'_, str>> for RiString<S>[src]

impl<S: Spec, T: Spec> PartialEq<RiAbsoluteStr<S>> for RiString<T>[src]

impl<S: Spec, T: Spec> PartialEq<RiAbsoluteString<S>> for RiString<T>[src]

impl<S: Spec, T: Spec> PartialEq<RiReferenceStr<T>> for RiString<S>[src]

impl<S: Spec, T: Spec> PartialEq<RiReferenceString<T>> for RiString<S>[src]

impl<S: Spec, T: Spec> PartialEq<RiStr<S>> for RiString<T>[src]

impl<S: Spec> PartialEq<RiString<S>> for str[src]

impl<'_, S: Spec> PartialEq<RiString<S>> for &'_ str[src]

impl<'_, S: Spec> PartialEq<RiString<S>> for Cow<'_, str>[src]

impl<S: Spec> PartialEq<RiString<S>> for String[src]

impl<S: Spec, T: Spec> PartialEq<RiString<S>> for RiReferenceStr<T>[src]

impl<'_, S: Spec, T: Spec> PartialEq<RiString<S>> for &'_ RiReferenceStr<T>[src]

impl<'_, S: Spec, T: Spec> PartialEq<RiString<S>> for Cow<'_, RiReferenceStr<T>>[src]

impl<S: Spec, T: Spec> PartialEq<RiString<S>> for RiReferenceString<T>[src]

impl<S: Spec, T: Spec> PartialEq<RiString<T>> for RiAbsoluteStr<S>[src]

impl<'_, S: Spec, T: Spec> PartialEq<RiString<T>> for &'_ RiAbsoluteStr<S>[src]

impl<'_, S: Spec, T: Spec> PartialEq<RiString<T>> for Cow<'_, RiAbsoluteStr<S>>[src]

impl<S: Spec, T: Spec> PartialEq<RiString<T>> for RiAbsoluteString<S>[src]

impl<S: Spec, T: Spec> PartialEq<RiString<T>> for RiString<S>[src]

impl<S: Spec, T: Spec> PartialEq<RiString<T>> for RiStr<S>[src]

impl<'_, S: Spec, T: Spec> PartialEq<RiString<T>> for &'_ RiStr<S>[src]

impl<'_, S: Spec, T: Spec> PartialEq<RiString<T>> for Cow<'_, RiStr<S>>[src]

impl<S: Spec> PartialEq<String> for RiString<S>[src]

impl<S: Spec> PartialEq<str> for RiString<S>[src]

impl<'_, S: Spec, T: Spec> PartialOrd<&'_ RiAbsoluteStr<S>> for RiString<T>[src]

impl<'_, S: Spec, T: Spec> PartialOrd<&'_ RiReferenceStr<T>> for RiString<S>[src]

impl<'_, S: Spec, T: Spec> PartialOrd<&'_ RiStr<S>> for RiString<T>[src]

impl<'_, S: Spec> PartialOrd<&'_ str> for RiString<S>[src]

impl<'_, S: Spec, T: Spec> PartialOrd<Cow<'_, RiAbsoluteStr<S>>> for RiString<T>[src]

impl<'_, S: Spec, T: Spec> PartialOrd<Cow<'_, RiReferenceStr<T>>> for RiString<S>[src]

impl<'_, S: Spec, T: Spec> PartialOrd<Cow<'_, RiStr<S>>> for RiString<T>[src]

impl<'_, S: Spec> PartialOrd<Cow<'_, str>> for RiString<S>[src]

impl<S: Spec, T: Spec> PartialOrd<RiAbsoluteStr<S>> for RiString<T>[src]

impl<S: Spec, T: Spec> PartialOrd<RiAbsoluteString<S>> for RiString<T>[src]

impl<S: Spec, T: Spec> PartialOrd<RiReferenceStr<T>> for RiString<S>[src]

impl<S: Spec, T: Spec> PartialOrd<RiReferenceString<T>> for RiString<S>[src]

impl<S: Spec, T: Spec> PartialOrd<RiStr<S>> for RiString<T>[src]

impl<S: Spec> PartialOrd<RiString<S>> for str[src]

impl<'_, S: Spec> PartialOrd<RiString<S>> for &'_ str[src]

impl<'_, S: Spec> PartialOrd<RiString<S>> for Cow<'_, str>[src]

impl<S: Spec> PartialOrd<RiString<S>> for String[src]

impl<S: Spec, T: Spec> PartialOrd<RiString<S>> for RiReferenceStr<T>[src]

impl<'_, S: Spec, T: Spec> PartialOrd<RiString<S>> for &'_ RiReferenceStr<T>[src]

impl<'_, S: Spec, T: Spec> PartialOrd<RiString<S>> for Cow<'_, RiReferenceStr<T>>[src]

impl<S: Spec, T: Spec> PartialOrd<RiString<S>> for RiReferenceString<T>[src]

impl<S: Spec, T: Spec> PartialOrd<RiString<T>> for RiAbsoluteStr<S>[src]

impl<'_, S: Spec, T: Spec> PartialOrd<RiString<T>> for &'_ RiAbsoluteStr<S>[src]

impl<'_, S: Spec, T: Spec> PartialOrd<RiString<T>> for Cow<'_, RiAbsoluteStr<S>>[src]

impl<S: Spec, T: Spec> PartialOrd<RiString<T>> for RiAbsoluteString<S>[src]

impl<S: Spec, T: Spec> PartialOrd<RiString<T>> for RiString<S>[src]

impl<S: Spec, T: Spec> PartialOrd<RiString<T>> for RiStr<S>[src]

impl<'_, S: Spec, T: Spec> PartialOrd<RiString<T>> for &'_ RiStr<S>[src]

impl<'_, S: Spec, T: Spec> PartialOrd<RiString<T>> for Cow<'_, RiStr<S>>[src]

impl<S: Spec> PartialOrd<String> for RiString<S>[src]

impl<S: Spec> PartialOrd<str> for RiString<S>[src]

impl<S> Serialize for RiString<S>[src]

impl<'_, S: Spec> TryFrom<&'_ str> for RiString<S>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<S: Spec> TryFrom<RiReferenceString<S>> for RiString<S>[src]

type Error = CreationError<RiReferenceString<S>>

The type returned in the event of a conversion error.

impl<S: Spec> TryFrom<RiString<S>> for RiAbsoluteString<S>[src]

type Error = CreationError<RiString<S>>

The type returned in the event of a conversion error.

impl<S: Spec> TryFrom<String> for RiString<S>[src]

type Error = CreationError<String>

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<S> RefUnwindSafe for RiString<S>

impl<S> Send for RiString<S>

impl<S> Sync for RiString<S>

impl<S> Unpin for RiString<S>

impl<S> UnwindSafe for RiString<S>

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> DeserializeOwned for T where
    T: Deserialize<'de>, 
[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.