Struct Strong

Source
pub struct Strong<Ctx: Validator> { /* private fields */ }
Expand description

Strongly typed str

Implementations§

Source§

impl<Ctx: Validator> Strong<Ctx>

Source

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

Constructs from str.

Source

pub unsafe fn no_validate<S: AsRef<str> + ?Sized>(s: &S) -> &Self

Constructs from str without validation.

§Safety

This function allows us to create invalid Strong.

Source

pub fn as_str(&self) -> &str

Converts to str.

Source

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

Source§

impl<Ctx: Validator> Strong<Ctx>

Source

pub fn valid(&self) -> Result<&Self, Ctx::Err>

Re-validates self

Source

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

Converts to StrongBuf.

Source

pub fn count_chars(&self) -> usize

Source

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

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

Source

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

Source

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

Source

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

Trait Implementations§

Source§

impl<'expr, Ctx: Validator> AsExpression<Nullable<SqlStrong<Ctx>>> for &'expr Strong<Ctx>

Source§

type Expression = Bound<Nullable<SqlStrong<Ctx>>, &'expr Strong<Ctx>>

The expression being returned
Source§

fn as_expression(self) -> Self::Expression

Perform the conversion
Source§

impl<'expr, Ctx: Validator> AsExpression<SqlStrong<Ctx>> for &'expr Strong<Ctx>

Source§

type Expression = Bound<SqlStrong<Ctx>, &'expr Strong<Ctx>>

The expression being returned
Source§

fn as_expression(self) -> Self::Expression

Perform the conversion
Source§

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

Source§

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

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

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

Source§

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

Immutably borrows from an owned value. Read more
Source§

impl<Ctx> Debug for Strong<Ctx>

Source§

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

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

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

Source§

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

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

impl<Ctx> Display for Strong<Ctx>

Source§

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

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

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

Needs allocation

Source§

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

Converts to this type from the input type.
Source§

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

Needs allocation

Source§

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

Converts to this type from the input type.
Source§

impl<'a, Ctx> From<&'a Strong<Ctx>> for Cow<'a, Strong<Ctx>>
where Ctx: Validator,

Source§

fn from(s: &'a Strong<Ctx>) -> Cow<'a, Strong<Ctx>>

Converts to this type from the input type.
Source§

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

Needs allocation

Source§

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

Converts to this type from the input type.
Source§

impl<Ctx> From<Cow<'_, Strong<Ctx>>> for Box<Strong<Ctx>>
where Ctx: Validator,

Source§

fn from(cow: Cow<'_, Strong<Ctx>>) -> Box<Strong<Ctx>>

Converts to this type from the input type.
Source§

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

Source§

fn from(s: StrongBuf<Ctx>) -> Self

Converts to this type from the input type.
Source§

impl<Ctx> Hash for Strong<Ctx>

Source§

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

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

impl<Ctx> Ord for Strong<Ctx>

Source§

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

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

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

Source§

fn eq(&self, other: &&'b 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.
Source§

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

Source§

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.
Source§

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

Source§

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.
Source§

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

Source§

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.
Source§

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

Source§

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.
Source§

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

Source§

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.
Source§

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

Source§

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.
Source§

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

Source§

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.
Source§

impl<Ctx> PartialEq for Strong<Ctx>

Source§

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.
Source§

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

Source§

fn partial_cmp(&self, other: &&'b 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
Source§

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

Source§

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
Source§

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

Source§

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
Source§

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

Source§

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
Source§

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

Source§

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
Source§

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

Source§

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
Source§

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

Source§

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
Source§

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

Source§

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
Source§

impl<Ctx> PartialOrd for Strong<Ctx>

Source§

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
Source§

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

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<Ctx> ToOwned for Strong<Ctx>
where Ctx: Validator,

Source§

type Owned = StrongBuf<Ctx>

The resulting type after obtaining ownership.
Source§

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
Source§

impl<Ctx: Validator, __DB> ToSql<Nullable<SqlStrong<Ctx>>, __DB> for Strong<Ctx>
where __DB: Backend, Self: ToSql<SqlStrong<Ctx>, __DB>,

Source§

fn to_sql<W: Write>(&self, out: &mut Output<'_, W, __DB>) -> Result

See the trait documentation.
Source§

impl<Ctx, DB> ToSql<SqlStrong<Ctx>, DB> for Strong<Ctx>

Source§

fn to_sql<W: Write>(&self, out: &mut Output<'_, W, DB>) -> Result

See the trait documentation.
Source§

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

Source§

type Error = <Ctx as Validator>::Err

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

fn try_from(s: &'a str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

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