pub struct Identifier {
pub namespace: String,
pub path: String,
}Expand description
A namespaced identifier in the format namespace:path.
Identifiers (also called ResourceLocations) are used throughout the
Minecraft protocol to reference game content: blocks (minecraft:stone),
items (minecraft:diamond), entities (minecraft:creeper), dimensions
(minecraft:overworld), registries, and plugin channels. They are
encoded on the wire as a single VarInt-prefixed UTF-8 string in the
format namespace:path.
The namespace defaults to minecraft when absent. Valid characters are:
- Namespace:
[a-z0-9._-] - Path:
[a-z0-9._-/]
Fields§
§namespace: StringThe namespace part (e.g., minecraft, mymod).
path: StringThe path part (e.g., stone, textures/block/dirt).
Implementations§
Source§impl Identifier
impl Identifier
Sourcepub fn new(
namespace: impl Into<String>,
path: impl Into<String>,
) -> Result<Self>
pub fn new( namespace: impl Into<String>, path: impl Into<String>, ) -> Result<Self>
Creates a new identifier with the given namespace and path.
Validates that both namespace and path contain only allowed characters.
Returns Error::InvalidData if validation fails.
Trait Implementations§
Source§impl Clone for Identifier
impl Clone for Identifier
Source§fn clone(&self) -> Identifier
fn clone(&self) -> Identifier
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Identifier
impl Debug for Identifier
Source§impl Decode for Identifier
Decodes an Identifier from a VarInt-prefixed UTF-8 string.
impl Decode for Identifier
Decodes an Identifier from a VarInt-prefixed UTF-8 string.
Reads the string using the standard Minecraft string decoding, then
parses it as namespace:path. If no colon is present, the namespace
defaults to minecraft. Validates that all characters are in the
allowed sets for namespace and path.
Source§impl Display for Identifier
Displays the identifier in namespace:path format.
impl Display for Identifier
Displays the identifier in namespace:path format.
Source§impl Encode for Identifier
Encodes an Identifier as a VarInt-prefixed UTF-8 string in namespace:path format.
impl Encode for Identifier
Encodes an Identifier as a VarInt-prefixed UTF-8 string in namespace:path format.
The full namespace:path string is written using the standard Minecraft
string encoding (VarInt length prefix + UTF-8 bytes). This is the same
wire format used for all string fields in the protocol.
Source§impl EncodedSize for Identifier
Computes the wire size of the identifier in namespace:path format.
impl EncodedSize for Identifier
Computes the wire size of the identifier in namespace:path format.
The total size includes the VarInt length prefix and the full
namespace:path UTF-8 byte count (including the colon separator).
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Returns the VarInt prefix size plus the byte length of namespace:path.
Source§impl Hash for Identifier
impl Hash for Identifier
Source§impl PartialEq for Identifier
impl PartialEq for Identifier
impl Eq for Identifier
impl StructuralPartialEq for Identifier
Auto Trait Implementations§
impl Freeze for Identifier
impl RefUnwindSafe for Identifier
impl Send for Identifier
impl Sync for Identifier
impl Unpin for Identifier
impl UnsafeUnpin for Identifier
impl UnwindSafe for Identifier
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
key and return true if they are equal.