Struct cm_types::BoundedName
source · pub struct BoundedName<const N: usize>(_);
Expand description
A BoundedName
is a Name
that can have a max length of N
bytes.
Implementations§
source§impl<const N: usize> BoundedName<N>
impl<const N: usize> BoundedName<N>
sourcepub fn try_new(name: impl AsRef<str> + Into<String>) -> Result<Self, ParseError>
pub fn try_new(name: impl AsRef<str> + Into<String>) -> Result<Self, ParseError>
Creates a BoundedName
from a String
, returning an Err
if the string
fails validation. The string must be non-empty, no more than N
characters in length, and consist of one or more of the
following characters: a-z
, 0-9
, _
, .
, -
.
pub fn validate(name: &str) -> Result<(), ParseError>
pub fn as_str(&self) -> &str
pub fn is_empty(&self) -> bool
Trait Implementations§
source§impl<const N: usize> Clone for BoundedName<N>
impl<const N: usize> Clone for BoundedName<N>
source§fn clone(&self) -> BoundedName<N>
fn clone(&self) -> BoundedName<N>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<const N: usize> Debug for BoundedName<N>
impl<const N: usize> Debug for BoundedName<N>
source§impl<'de, const N: usize> Deserialize<'de> for BoundedName<N>
impl<'de, const N: usize> Deserialize<'de> for BoundedName<N>
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
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<const N: usize> Display for BoundedName<N>
impl<const N: usize> Display for BoundedName<N>
source§impl<const N: usize> From<BoundedName<N>> for String
impl<const N: usize> From<BoundedName<N>> for String
source§fn from(name: BoundedName<N>) -> String
fn from(name: BoundedName<N>) -> String
Converts to this type from the input type.
source§impl<const N: usize> FromStr for BoundedName<N>
impl<const N: usize> FromStr for BoundedName<N>
source§impl<const N: usize> Hash for BoundedName<N>
impl<const N: usize> Hash for BoundedName<N>
source§impl<const N: usize> Ord for BoundedName<N>
impl<const N: usize> Ord for BoundedName<N>
source§fn cmp(&self, other: &BoundedName<N>) -> Ordering
fn cmp(&self, other: &BoundedName<N>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<const N: usize> PartialEq<BoundedName<N>> for BoundedName<N>
impl<const N: usize> PartialEq<BoundedName<N>> for BoundedName<N>
source§fn eq(&self, other: &BoundedName<N>) -> bool
fn eq(&self, other: &BoundedName<N>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<const N: usize> PartialOrd<BoundedName<N>> for BoundedName<N>
impl<const N: usize> PartialOrd<BoundedName<N>> for BoundedName<N>
source§fn partial_cmp(&self, other: &BoundedName<N>) -> Option<Ordering>
fn partial_cmp(&self, other: &BoundedName<N>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more