strck

Struct Ck

source
#[repr(transparent)]
pub struct Ck<I: Invariant> { pub(crate) _marker: PhantomData<I>, pub(crate) slice: str, }
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.

Fields§

§_marker: PhantomData<I>§slice: str

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§

default fn to_string(&self) -> String

Converts the given value to a String. Read more