Ck

Struct Ck 

Source
pub struct Ck<I: Invariant> { /* private fields */ }
Expand description

Borrowed immutable string with invariants.

Ck is a DST, and therefore must always live behind a pointer. This means you’ll usually see it as &Ck<I> in type signatures.

§Deserialization

See the crate-level documentation for details on how to use Ck for checked zero-copy deserialization.

Implementations§

Source§

impl<I: Invariant> Ck<I>

Source

pub fn from_slice(slice: &str) -> Result<&Self, I::Error>

Returns an Ok if the &str upholds the invariants, otherwise Err.

Source

pub unsafe fn from_str_unchecked(slice: &str) -> &Self

Create a new &Ck without validating the &str.

§Safety

The string must be valid.

Source

pub fn to_check<'a, B>(&'a self) -> Check<I, B>
where B: AsRef<str> + From<&'a str>,

Returns an owned Check from &self.

Source

pub fn as_str(&self) -> &str

Returns the &str representation.

Trait Implementations§

Source§

impl<I: Invariant, B: AsRef<str>> AsRef<Ck<I>> for Check<I, B>

Source§

fn as_ref(&self) -> &Ck<I>

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

impl<I: Invariant> AsRef<str> for Ck<I>

Source§

fn as_ref(&self) -> &str

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

impl<I: Invariant, B: AsRef<str>> Borrow<Ck<I>> for Check<I, B>

Source§

fn borrow(&self) -> &Ck<I>

Immutably borrows from an owned value. Read more
Source§

impl<I: Invariant> Borrow<str> for Ck<I>

Source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
Source§

impl<I: Invariant> Debug for Ck<I>

Source§

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

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

impl<I: Invariant> Display for Ck<I>

Source§

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

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

impl<'a, I: Invariant, B: AsRef<str>> From<&'a Check<I, B>> for &'a Ck<I>

Source§

fn from(check: &'a Check<I, B>) -> Self

Converts to this type from the input type.
Source§

impl<'a, I, B> From<&'a Ck<I>> for Check<I, B>
where I: Invariant, B: AsRef<str> + From<&'a str>,

Source§

fn from(check: &'a Ck<I>) -> Self

Converts to this type from the input type.
Source§

impl<I: Invariant> Hash for Ck<I>

Source§

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

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

impl<I: Invariant> Ord for Ck<I>

Source§

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

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

impl<'a, I: Invariant, B: AsRef<str>> PartialEq<&'a Check<I, B>> for Ck<I>

Source§

fn eq(&self, other: &&'a Check<I, B>) -> 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, I: Invariant, B: AsRef<str>> PartialEq<&'a Ck<I>> for Check<I, B>

Source§

fn eq(&self, other: &&'a Ck<I>) -> 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, I: Invariant> PartialEq<&'a Ck<I>> for Ck<I>

Source§

fn eq(&self, other: &&'a Ck<I>) -> 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, I: Invariant> PartialEq<&'a Ck<I>> for String

Source§

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

Source§

fn eq(&self, other: &&'a Ck<I>) -> 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, I: Invariant> PartialEq<&'a String> for Ck<I>

Source§

fn eq(&self, other: &&'a String) -> 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, I: Invariant> PartialEq<&'a str> for Ck<I>

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<'a, I: Invariant, B: AsRef<str>> PartialEq<Check<I, B>> for &'a Ck<I>

Source§

fn eq(&self, other: &Check<I, B>) -> 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<I: Invariant, B: AsRef<str>> PartialEq<Check<I, B>> for Ck<I>

Source§

fn eq(&self, other: &Check<I, B>) -> 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, I: Invariant, B: AsRef<str>> PartialEq<Ck<I>> for &'a Check<I, B>

Source§

fn eq(&self, other: &Ck<I>) -> 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, I: Invariant> PartialEq<Ck<I>> for &'a Ck<I>

Source§

fn eq(&self, other: &Ck<I>) -> 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, I: Invariant> PartialEq<Ck<I>> for &'a String

Source§

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

Source§

fn eq(&self, other: &Ck<I>) -> 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<I: Invariant, B: AsRef<str>> PartialEq<Ck<I>> for Check<I, B>

Source§

fn eq(&self, other: &Ck<I>) -> 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<I: Invariant> PartialEq<Ck<I>> for String

Source§

fn eq(&self, other: &Ck<I>) -> 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<I: Invariant> PartialEq<Ck<I>> for str

Source§

fn eq(&self, other: &Ck<I>) -> 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, I: Invariant> PartialEq<String> for &'a Ck<I>

Source§

fn eq(&self, other: &String) -> 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<I: Invariant> PartialEq<String> for Ck<I>

Source§

fn eq(&self, other: &String) -> 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, I: Invariant> PartialEq<str> for &'a Ck<I>

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<I: Invariant> PartialEq<str> for Ck<I>

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<I: Invariant> PartialEq for Ck<I>

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<I: Invariant> PartialOrd for Ck<I>

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<I: Invariant> ToOwned for Ck<I>

Source§

type Owned = Check<I>

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<'a, I: Invariant> TryFrom<&'a str> for &'a Ck<I>

Source§

type Error = <I as Invariant>::Error

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

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

Performs the conversion.
Source§

impl<I: Invariant> Eq for Ck<I>

Auto Trait Implementations§

§

impl<I> Freeze for Ck<I>

§

impl<I> RefUnwindSafe for Ck<I>
where I: RefUnwindSafe,

§

impl<I> Send for Ck<I>
where I: Send,

§

impl<I> !Sized for Ck<I>

§

impl<I> Sync for Ck<I>
where I: Sync,

§

impl<I> Unpin for Ck<I>
where I: Unpin,

§

impl<I> UnwindSafe for Ck<I>
where I: 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

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: (unsized)