Type Alias IriQueryStr

Source
pub type IriQueryStr = RiQueryStr<IriSpec>;
Expand description

A type alias for RiQueryStr<IriSpec>.

Aliased Type§

pub struct IriQueryStr { /* private fields */ }

Implementations§

Source§

impl IriQueryStr

Conversion from an IRI into a URI.

Source

pub fn encode_to_uri(&self) -> MappedToUri<'_, Self>

Percent-encodes the IRI into a valid URI that identifies the equivalent resource.

If you need more precise control over memory allocation and buffer handling, use MappedToUri type.

§Examples
use iri_string::format::ToDedicatedString;
use iri_string::types::{IriQueryStr, UriQueryString};

let iri = IriQueryStr::new("alpha-is-\u{03B1}")?;
// Type annotation here is not necessary.
let uri: UriQueryString = iri.encode_to_uri().to_dedicated_string();
assert_eq!(uri, "alpha-is-%CE%B1");
Source

pub fn as_uri(&self) -> Option<&UriQueryStr>

Converts an IRI into a URI without modification, if possible.

This is semantically equivalent to UriQueryStr::new(self.as_str()).ok().

§Examples
use iri_string::types::{IriQueryStr, UriQueryStr};

let ascii_iri = IriQueryStr::new("alpha-is-%CE%B1")?;
assert_eq!(
    ascii_iri.as_uri().map(AsRef::as_ref),
    Some("alpha-is-%CE%B1")
);

let nonascii_iri = IriQueryStr::new("alpha-is-\u{03B1}")?;
assert_eq!(nonascii_iri.as_uri(), None);
Source§

impl<S: Spec> RiQueryStr<S>

Source

pub fn from_prefixed(s: &str) -> Result<&Self, Error>

Creates a new &RiQueryStr from the query part prefixed by ?.

§Examples
assert!(IriQueryStr::from_prefixed("?").is_ok());
assert!(IriQueryStr::from_prefixed("?foo").is_ok());
assert!(IriQueryStr::from_prefixed("?foo/bar").is_ok());
assert!(IriQueryStr::from_prefixed("?/foo/bar").is_ok());
assert!(IriQueryStr::from_prefixed("?//foo/bar").is_ok());
assert!(IriQueryStr::from_prefixed("?https://user:pass@example.com:8080").is_ok());
assert!(IriQueryStr::from_prefixed("?https://example.com/").is_ok());
// Question sign `?` can appear in an IRI query.
assert!(IriQueryStr::from_prefixed("?query?again").is_ok());

// `<` and `>` cannot directly appear in an IRI.
assert!(IriQueryStr::from_prefixed("?<not allowed>").is_err());
// Broken percent encoding cannot appear in an IRI.
assert!(IriQueryStr::new("?%").is_err());
assert!(IriQueryStr::new("?%GG").is_err());
// `?` prefix is expected.
assert!(IriQueryStr::from_prefixed("").is_err());
assert!(IriQueryStr::from_prefixed("foo").is_err());
// Hash sign `#` cannot appear in an IRI query.
assert!(IriQueryStr::from_prefixed("?#hash").is_err());
Source§

impl<S: Spec> RiQueryStr<S>

Source

pub fn new(s: &str) -> Result<&Self, Error>

Creates a new string.

Source

pub unsafe fn new_unchecked(s: &str) -> &Self

Creates a new string without validation.

This does not validate the given string, so it is caller’s responsibility to ensure the given string is valid.

§Safety

The given string must be syntactically valid as Self type. If not, any use of the returned value or the call of this function itself may result in undefined behavior.

Source

pub fn as_str(&self) -> &str

Returns &str.

Source

pub fn len(&self) -> usize

Returns the string length.

Source

pub fn is_empty(&self) -> bool

Returns whether the string is empty.

Trait Implementations

Source§

impl<S: Spec> AsRef<RiQueryStr<S>> for RiQueryStr<S>

Source§

fn as_ref(&self) -> &RiQueryStr<S>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<S: Spec> AsRef<str> for RiQueryStr<S>

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<S: Spec> Debug for RiQueryStr<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: Spec> Display for RiQueryStr<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: Spec> Hash for RiQueryStr<S>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl<S: Spec> Ord for RiQueryStr<S>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl<S: Spec, T: Spec> PartialEq<&RiQueryStr<S>> for RiQueryStr<T>

Source§

fn eq(&self, o: &&RiQueryStr<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Spec> PartialEq<&str> for RiQueryStr<S>

Source§

fn eq(&self, o: &&str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Spec> PartialEq<Cow<'_, str>> for RiQueryStr<S>

Source§

fn eq(&self, o: &Cow<'_, str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Spec, T: Spec> PartialEq<RiQueryString<T>> for RiQueryStr<S>

Source§

fn eq(&self, o: &RiQueryString<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Spec> PartialEq<str> for RiQueryStr<S>

Source§

fn eq(&self, o: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Spec> PartialEq for RiQueryStr<S>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Spec, T: Spec> PartialOrd<&RiQueryStr<S>> for RiQueryStr<T>

Source§

fn partial_cmp(&self, o: &&RiQueryStr<S>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S: Spec> PartialOrd<&str> for RiQueryStr<S>

Source§

fn partial_cmp(&self, o: &&str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S: Spec> PartialOrd<Cow<'_, str>> for RiQueryStr<S>

Source§

fn partial_cmp(&self, o: &Cow<'_, str>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S: Spec, T: Spec> PartialOrd<RiQueryString<T>> for RiQueryStr<S>

Source§

fn partial_cmp(&self, o: &RiQueryString<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S: Spec> PartialOrd<str> for RiQueryStr<S>

Source§

fn partial_cmp(&self, o: &str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S: Spec> PartialOrd for RiQueryStr<S>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S> Serialize for RiQueryStr<S>
where S: Spec,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<S: Spec> ToOwned for RiQueryStr<S>

Source§

type Owned = RiQueryString<S>

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<S: Spec> Eq for RiQueryStr<S>