Struct UnregisteredScheme

Source
pub struct UnregisteredScheme<'scheme> { /* private fields */ }
Expand description

A scheme that is not in the registered schemes.

This is case-insensitive, and this is reflected in the equality and hash functions.

Implementations§

Source§

impl UnregisteredScheme<'_>

Source

pub fn as_borrowed(&self) -> UnregisteredScheme<'_>

Returns a new unregistered scheme which is identical but has a lifetime tied to this unregistered scheme.

Source

pub fn as_str(&self) -> &str

Returns a str representation of the scheme.

The case-sensitivity of the original string is preserved.

§Examples
use std::convert::TryFrom;

use uriparse::UnregisteredScheme;

let scheme = UnregisteredScheme::try_from("TEST-scheme").unwrap();
assert_eq!(scheme.as_str(), "TEST-scheme");
Source

pub fn into_owned(self) -> UnregisteredScheme<'static>

Converts the UnregisteredScheme into an owned copy.

If you construct the scheme from a source with a non-static lifetime, you may run into lifetime problems due to the way the struct is designed. Calling this function will ensure that the returned value has a static lifetime.

This is different from just cloning. Cloning the scheme will just copy the references, and thus the lifetime will remain the same.

Source

pub fn is_normalized(&self) -> bool

Returns whether the scheme is normalized.

A normalized scheme will be all lowercase.

This function runs in constant-time.

§Examples
use std::convert::TryFrom;

use uriparse::UnregisteredScheme;

let scheme = UnregisteredScheme::try_from("myscheme").unwrap();
assert!(scheme.is_normalized());

let mut scheme = UnregisteredScheme::try_from("MyScHeMe").unwrap();
assert!(!scheme.is_normalized());
scheme.normalize();
assert!(scheme.is_normalized());
Source

pub fn normalize(&mut self)

Normalizes the scheme so that it is all lowercase.

§Examples
use std::convert::TryFrom;

use uriparse::UnregisteredScheme;

let mut scheme = UnregisteredScheme::try_from("myscheme").unwrap();
scheme.normalize();
assert_eq!(scheme, "myscheme");

let mut scheme = UnregisteredScheme::try_from("MyScHeMe").unwrap();
scheme.normalize();
assert_eq!(scheme, "myscheme");

Trait Implementations§

Source§

impl AsRef<[u8]> for UnregisteredScheme<'_>

Source§

fn as_ref(&self) -> &[u8]

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

impl AsRef<str> for UnregisteredScheme<'_>

Source§

fn as_ref(&self) -> &str

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

impl<'scheme> Clone for UnregisteredScheme<'scheme>

Source§

fn clone(&self) -> UnregisteredScheme<'scheme>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'scheme> Debug for UnregisteredScheme<'scheme>

Source§

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

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

impl Display for UnregisteredScheme<'_>

Source§

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

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

impl<'scheme> From<UnregisteredScheme<'scheme>> for String

Source§

fn from(value: UnregisteredScheme<'scheme>) -> Self

Converts to this type from the input type.
Source§

impl Hash for UnregisteredScheme<'_>

Source§

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

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

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> PartialEq<&'a [u8]> for UnregisteredScheme<'_>

Source§

fn eq(&self, other: &&'a [u8]) -> 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<'a> PartialEq<&'a str> for UnregisteredScheme<'_>

Source§

fn eq(&self, other: &&'a 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 PartialEq<[u8]> for UnregisteredScheme<'_>

Source§

fn eq(&self, other: &[u8]) -> 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<'a, 'scheme> PartialEq<UnregisteredScheme<'scheme>> for &'a [u8]

Source§

fn eq(&self, other: &UnregisteredScheme<'scheme>) -> 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<'a, 'scheme> PartialEq<UnregisteredScheme<'scheme>> for &'a str

Source§

fn eq(&self, other: &UnregisteredScheme<'scheme>) -> 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<'scheme> PartialEq<UnregisteredScheme<'scheme>> for [u8]

Source§

fn eq(&self, other: &UnregisteredScheme<'scheme>) -> 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<'scheme> PartialEq<UnregisteredScheme<'scheme>> for str

Source§

fn eq(&self, other: &UnregisteredScheme<'scheme>) -> 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 PartialEq<str> for UnregisteredScheme<'_>

Source§

fn eq(&self, other: &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 PartialEq for UnregisteredScheme<'_>

Source§

fn eq(&self, other: &UnregisteredScheme<'_>) -> 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<'scheme> TryFrom<&'scheme [u8]> for UnregisteredScheme<'scheme>

Source§

type Error = UnregisteredSchemeError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &'scheme [u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'scheme> TryFrom<&'scheme str> for UnregisteredScheme<'scheme>

Source§

type Error = UnregisteredSchemeError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &'scheme str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for UnregisteredScheme<'_>

Auto Trait Implementations§

§

impl<'scheme> Freeze for UnregisteredScheme<'scheme>

§

impl<'scheme> RefUnwindSafe for UnregisteredScheme<'scheme>

§

impl<'scheme> Send for UnregisteredScheme<'scheme>

§

impl<'scheme> Sync for UnregisteredScheme<'scheme>

§

impl<'scheme> Unpin for UnregisteredScheme<'scheme>

§

impl<'scheme> UnwindSafe for UnregisteredScheme<'scheme>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.