Struct valence_protocol::Ident
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§
§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
pub fn namespace(&self) -> &str
pub fn namespace(&self) -> &str
Returns the namespace part of this resource identifier (the part before the colon).
pub 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§
§impl<'de, S> Deserialize<'de> for Ident<S>
impl<'de, S> Deserialize<'de> for Ident<S>
§fn deserialize<D>(
deserializer: D,
) -> Result<Ident<S>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Ident<S>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl<S> Ord for Ident<S>where
S: Ord,
impl<S> Ord for Ident<S>where
S: Ord,
§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<T> Serialize for Ident<T>where
T: Serialize,
impl<T> Serialize for Ident<T>where
T: Serialize,
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<S> Copy for Ident<S>where
S: Copy,
impl<S> Eq for Ident<S>where
S: Eq,
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
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DynEq for T
impl<T> DynEq for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.