pub struct ModelIdentifier;Expand description
Helper methods for dealing with model identifiers.
§Why does this exist?
Prior to 1.13, model identifiers found in
assets/<namespace>/blockstates/*.json did not include a prefix like
block/ or item/ to disambiguate between different types of models.
Because of this, the minecraft-assets API forces the user to always
specify which type of model they are trying to reference (note the existence
of both BlockModel and ItemModel variants in ResourceKind). This
way, the API will work with versions prior to 1.13.
So this struct is meant to wrap an identifier and extract its model name.
See the model_name() documentation for more information.
Implementations§
Source§impl ModelIdentifier
impl ModelIdentifier
Sourcepub fn model_name(id: &str) -> &str
pub fn model_name(id: &str) -> &str
Returns the name of the model, stripping the leading path component if there is one.
§Example
assert_eq!(ModelIdentifier::model_name("stone"), "stone");
assert_eq!(ModelIdentifier::model_name("block/oak_planks"), "oak_planks");
assert_eq!(ModelIdentifier::model_name("item/diamond_hoe"), "diamond_hoe");Trait Implementations§
Source§impl Clone for ModelIdentifier
impl Clone for ModelIdentifier
Source§fn clone(&self) -> ModelIdentifier
fn clone(&self) -> ModelIdentifier
Returns a duplicate 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 Debug for ModelIdentifier
impl Debug for ModelIdentifier
Auto Trait Implementations§
impl Freeze for ModelIdentifier
impl RefUnwindSafe for ModelIdentifier
impl Send for ModelIdentifier
impl Sync for ModelIdentifier
impl Unpin for ModelIdentifier
impl UnwindSafe for ModelIdentifier
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