Strong

Struct Strong 

#[repr(transparent)]
pub struct Strong<Ctx>
where Ctx: Validator,
{ phantom: PhantomData<Ctx>, inner: str, }
Expand description

Strongly typed str

Fields§

§phantom: PhantomData<Ctx>§inner: str

Implementations§

§

impl<Ctx> Strong<Ctx>
where Ctx: Validator,

pub fn validate<S>(s: &S) -> Result<&Strong<Ctx>, <Ctx as Validator>::Err>
where S: AsRef<str> + ?Sized,

Constructs from str.

pub unsafe fn no_validate<S>(s: &S) -> &Strong<Ctx>
where S: AsRef<str> + ?Sized,

Constructs from str without validation.

§Safety

This function allows us to create invalid Strong.

pub fn as_str(&self) -> &str

Converts to str.

pub fn as_bytes(&self) -> &[u8]

§

impl<Ctx> Strong<Ctx>
where Ctx: Validator,

pub fn valid(&self) -> Result<&Strong<Ctx>, <Ctx as Validator>::Err>

Re-validates self

pub fn to_strong_buf(&self) -> StrongBuf<Ctx>

Converts to StrongBuf.

pub fn count_chars(&self) -> usize

pub fn map<F>(&self, f: F) -> Result<&Strong<Ctx>, <Ctx as Validator>::Err>
where F: FnOnce(&str) -> &str,

Map with function: &str -> &str and validation

pub fn trim(&self) -> Result<&Strong<Ctx>, <Ctx as Validator>::Err>

pub fn trim_start(&self) -> Result<&Strong<Ctx>, <Ctx as Validator>::Err>

pub fn trim_end(&self) -> Result<&Strong<Ctx>, <Ctx as Validator>::Err>

Trait Implementations§

§

impl<Ctx> AsRef<Strong<Ctx>> for StrongBuf<Ctx>
where Ctx: Validator,

§

fn as_ref(&self) -> &Strong<Ctx>

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

impl<Ctx> Borrow<Strong<Ctx>> for StrongBuf<Ctx>
where Ctx: Validator,

§

fn borrow(&self) -> &Strong<Ctx>

Immutably borrows from an owned value. Read more
§

impl<Ctx> Debug for Strong<Ctx>

§

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

Formats the value using the given formatter. Read more
§

impl<'de, Ctx> Deserialize<'de> for &'de Strong<Ctx>
where Ctx: Validator, <Ctx as Validator>::Err: Display,

§

fn deserialize<D>( deserializer: D, ) -> Result<&'de Strong<Ctx>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl<Ctx> Display for Strong<Ctx>

§

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

Formats the value using the given formatter. Read more
§

impl<Ctx> From<&Strong<Ctx>> for Arc<Strong<Ctx>>
where Ctx: Validator,

Needs allocation

§

fn from(s: &Strong<Ctx>) -> Arc<Strong<Ctx>>

Converts to this type from the input type.
§

impl<Ctx> Hash for Strong<Ctx>

§

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

Feeds this value into the given Hasher. Read more
§

impl<Ctx> Ord for Strong<Ctx>

§

fn cmp(&self, other: &Strong<Ctx>) -> Ordering

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

impl<'a, 'b, Ctx> PartialEq<&'a Strong<Ctx>> for StrongBuf<Ctx>

§

fn eq(&self, other: &&'a Strong<Ctx>) -> 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.
§

impl<'a, 'b, Ctx> PartialEq<Cow<'a, Strong<Ctx>>> for &'b Strong<Ctx>

§

fn eq(&self, other: &Cow<'a, Strong<Ctx>>) -> 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.
§

impl<'a, 'b, Ctx> PartialEq<Cow<'a, Strong<Ctx>>> for Strong<Ctx>

§

fn eq(&self, other: &Cow<'a, Strong<Ctx>>) -> 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.
§

impl<'a, 'b, Ctx> PartialEq<Strong<Ctx>> for StrongBuf<Ctx>

§

fn eq(&self, other: &Strong<Ctx>) -> 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.
§

impl<'a, 'b, Ctx> PartialEq<StrongBuf<Ctx>> for &'a Strong<Ctx>

§

fn eq(&self, other: &StrongBuf<Ctx>) -> 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.
§

impl<'a, 'b, Ctx> PartialEq<StrongBuf<Ctx>> for Strong<Ctx>

§

fn eq(&self, other: &StrongBuf<Ctx>) -> 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.
§

impl<Ctx> PartialEq for Strong<Ctx>

§

fn eq(&self, other: &Strong<Ctx>) -> 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.
§

impl<'a, 'b, Ctx> PartialOrd<&'a Strong<Ctx>> for StrongBuf<Ctx>

§

fn partial_cmp(&self, other: &&'a Strong<Ctx>) -> 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
§

impl<'a, 'b, Ctx> PartialOrd<Cow<'a, Strong<Ctx>>> for &'b Strong<Ctx>

§

fn partial_cmp(&self, other: &Cow<'a, Strong<Ctx>>) -> 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
§

impl<'a, 'b, Ctx> PartialOrd<Cow<'a, Strong<Ctx>>> for Strong<Ctx>

§

fn partial_cmp(&self, other: &Cow<'a, Strong<Ctx>>) -> 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
§

impl<'a, 'b, Ctx> PartialOrd<Strong<Ctx>> for StrongBuf<Ctx>

§

fn partial_cmp(&self, other: &Strong<Ctx>) -> 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
§

impl<'a, 'b, Ctx> PartialOrd<StrongBuf<Ctx>> for &'a Strong<Ctx>

§

fn partial_cmp(&self, other: &StrongBuf<Ctx>) -> 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
§

impl<'a, 'b, Ctx> PartialOrd<StrongBuf<Ctx>> for Strong<Ctx>

§

fn partial_cmp(&self, other: &StrongBuf<Ctx>) -> 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
§

impl<Ctx> PartialOrd for Strong<Ctx>

§

fn partial_cmp(&self, other: &Strong<Ctx>) -> 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
§

impl<Ctx> Serialize for Strong<Ctx>
where Ctx: Validator,

§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

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

impl<Ctx> ToOwned for Strong<Ctx>
where Ctx: Validator,

§

type Owned = StrongBuf<Ctx>

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> StrongBuf<Ctx>

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
§

impl<'a, Ctx> TryFrom<&'a str> for &'a Strong<Ctx>
where Ctx: Validator,

§

type Error = <Ctx as Validator>::Err

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

fn try_from( s: &'a str, ) -> Result<&'a Strong<Ctx>, <&'a Strong<Ctx> as TryFrom<&'a str>>::Error>

Performs the conversion.
§

impl<Ctx> Eq for Strong<Ctx>

Auto Trait Implementations§

§

impl<Ctx> Freeze for Strong<Ctx>

§

impl<Ctx> RefUnwindSafe for Strong<Ctx>
where Ctx: RefUnwindSafe,

§

impl<Ctx> Send for Strong<Ctx>
where Ctx: Send,

§

impl<Ctx> !Sized for Strong<Ctx>

§

impl<Ctx> Sync for Strong<Ctx>
where Ctx: Sync,

§

impl<Ctx> Unpin for Strong<Ctx>
where Ctx: Unpin,

§

impl<Ctx> UnwindSafe for Strong<Ctx>
where Ctx: UnwindSafe,

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
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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