pub struct ComponentName(/* private fields */);Expand description
A key under one of the Components maps.
The specification restricts these to ^[a-zA-Z0-9.\-_]+$, which is narrower
than most Rust type names allow — Vec<User> cannot be a component name, so
generic types have to be mangled into one.
Implementations§
Source§impl ComponentName
impl ComponentName
Sourcepub fn new(name: impl Into<String>) -> Result<Self, InvalidComponentName>
pub fn new(name: impl Into<String>) -> Result<Self, InvalidComponentName>
Validates and wraps a component name.
§Errors
Returns InvalidComponentName when name is empty or contains a
character outside A-Z a-z 0-9 . - _.
Sourcepub fn is_valid_char(c: char) -> bool
pub fn is_valid_char(c: char) -> bool
Whether c may appear in a component name.
Sourcepub fn sanitized(name: &str) -> Result<Self, InvalidComponentName>
pub fn sanitized(name: &str) -> Result<Self, InvalidComponentName>
Rewrites name into a legal component name.
Illegal characters are replaced with _, and runs of them collapse.
This is how a generic Rust type name becomes a component key.
§Errors
Returns InvalidComponentName when nothing legal survives, which
happens only for an empty input.
Trait Implementations§
Source§impl Clone for ComponentName
impl Clone for ComponentName
Source§impl Debug for ComponentName
impl Debug for ComponentName
Source§impl<'de> Deserialize<'de> for ComponentName
impl<'de> Deserialize<'de> for ComponentName
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 Display for ComponentName
impl Display for ComponentName
impl Eq for ComponentName
Source§impl From<ComponentName> for String
impl From<ComponentName> for String
Source§fn from(name: ComponentName) -> Self
fn from(name: ComponentName) -> Self
Converts to this type from the input type.
Source§impl Hash for ComponentName
impl Hash for ComponentName
Source§impl Ord for ComponentName
impl Ord for ComponentName
1.21.0 (const: unstable) · 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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for ComponentName
impl PartialEq for ComponentName
Source§impl PartialOrd for ComponentName
impl PartialOrd for ComponentName
Source§impl Serialize for ComponentName
impl Serialize for ComponentName
impl StructuralPartialEq for ComponentName
Auto Trait Implementations§
impl Freeze for ComponentName
impl RefUnwindSafe for ComponentName
impl Send for ComponentName
impl Sync for ComponentName
impl Unpin for ComponentName
impl UnsafeUnpin for ComponentName
impl UnwindSafe for ComponentName
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.