Str

Struct Str 

pub struct Str<Ctx>
where Ctx: Validator,
{ phantom: PhantomData<Ctx>, inner: String, }
Expand description

Strongly typed String

Fields§

§phantom: PhantomData<Ctx>§inner: String

Implementations§

§

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

pub fn validate(s: String) -> Result<StrongBuf<Ctx>, <Ctx as Validator>::Err>

Constructs from String.

pub unsafe fn no_validate(s: String) -> StrongBuf<Ctx>

Constructs from String without validation.

§Safety

This function allows us to create invalid StrongBuf.

pub fn into_string(self) -> String

Converts to String.

pub fn as_strong(&self) -> &Strong<Ctx>

§

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

pub unsafe fn from_utf8_unchecked(bytes: Vec<u8>) -> StrongBuf<Ctx>

Constructs from Vec<u8> without validation.

§Safety

This function allows us to create invalid StrongBuf, and it may not even be a valid utf-8.

pub fn into_boxed_strong(self) -> Box<Strong<Ctx>>

Methods from Deref<Target = Strong<Ctx>>§

pub fn as_str(&self) -> &str

Converts to str.

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

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> Clone for StrongBuf<Ctx>
where Ctx: Validator,

§

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

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

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

Performs copy-assignment from source. Read more
§

impl<Ctx> Debug for StrongBuf<Ctx>

§

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

Formats the value using the given formatter. Read more
§

impl<Ctx> Deref for StrongBuf<Ctx>
where Ctx: Validator,

§

type Target = Strong<Ctx>

The resulting type after dereferencing.
§

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

Dereferences the value.
§

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

§

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

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

impl<Ctx> Display for StrongBuf<Ctx>

§

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

Formats the value using the given formatter. Read more
§

impl<Ctx> From<Box<Strong<Ctx>>> for StrongBuf<Ctx>
where Ctx: Validator,

§

fn from(boxed: Box<Strong<Ctx>>) -> StrongBuf<Ctx>

Converts to this type from the input type.
§

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

§

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

Converts to this type from the input type.
§

impl<Ctx> FromStr for StrongBuf<Ctx>
where Ctx: Validator,

§

type Err = <Ctx as Validator>::Err

The associated error which can be returned from parsing.
§

fn from_str(s: &str) -> Result<StrongBuf<Ctx>, <StrongBuf<Ctx> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
§

impl<Ctx> Hash for StrongBuf<Ctx>

§

fn hash<H>(&self, h: &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
§

impl<Ctx> Ord for StrongBuf<Ctx>

§

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

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

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. 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 StrongBuf<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 StrongBuf<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> 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 StrongBuf<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 StrongBuf<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> Serialize for StrongBuf<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> TryFrom<String> for StrongBuf<Ctx>
where Ctx: Validator,

§

type Error = <Ctx as Validator>::Err

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

fn try_from( s: String, ) -> Result<StrongBuf<Ctx>, <StrongBuf<Ctx> as TryFrom<String>>::Error>

Performs the conversion.
§

impl<Ctx> Eq for StrongBuf<Ctx>

Auto Trait Implementations§

§

impl<Ctx> Freeze for StrongBuf<Ctx>

§

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

§

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

§

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

§

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

§

impl<Ctx> UnwindSafe for StrongBuf<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
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
§

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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

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