Struct valence_ident::Ident
source · pub struct Ident<S> { /* private fields */ }
Expand description
A wrapper around a string type S
which guarantees the wrapped string is a
valid resource identifier.
A resource identifier is a string divided into a “namespace” part and a
“path” part. For instance minecraft:apple
and valence:frobnicator
are
both valid identifiers. A string must match the regex
^([a-z0-9_.-]+:)?[a-z0-9_.-\/]+$
to be successfully parsed.
While parsing, if the namespace part is left off (the part before and including the colon) then “minecraft:” is inserted at the beginning of the string.
Implementations§
source§impl<S> Ident<S>
impl<S> Ident<S>
pub fn as_str(&self) -> &str
pub fn as_str_ident(&self) -> Ident<&str>
pub fn to_string_ident(&self) -> Ident<String>
pub fn into_inner(self) -> S
sourcepub fn namespace(&self) -> &str
pub fn namespace(&self) -> &str
Returns the namespace part of this resource identifier (the part before the colon).
sourcepub fn path(&self) -> &str
pub fn path(&self) -> &str
Returns the path part of this resource identifier (the part after the colon).
pub fn namespace_and_path(&self) -> (&str, &str)
Trait Implementations§
source§impl<'de, S> Deserialize<'de> for Ident<S>
impl<'de, S> Deserialize<'de> for Ident<S>
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<S: Ord> Ord for Ident<S>
impl<S: Ord> Ord for Ident<S>
source§impl<S, T> PartialOrd<Ident<T>> for Ident<S>where
S: PartialOrd<T>,
impl<S, T> PartialOrd<Ident<T>> for Ident<S>where
S: PartialOrd<T>,
impl<S: Copy> Copy for Ident<S>
impl<S: Eq> Eq for Ident<S>
Auto Trait Implementations§
impl<S> Freeze for Ident<S>where
S: Freeze,
impl<S> RefUnwindSafe for Ident<S>where
S: RefUnwindSafe,
impl<S> Send for Ident<S>where
S: Send,
impl<S> Sync for Ident<S>where
S: Sync,
impl<S> Unpin for Ident<S>where
S: Unpin,
impl<S> UnwindSafe for Ident<S>where
S: UnwindSafe,
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)