Struct minecraft_assets::schemas::models::Texture [−][src]
pub struct Texture(pub String);
Expand description
The value of a texture variable in the Textures
map.
The string value will either specify a location
to load the texture from
or a reference
to another texture variable to take its value from.
Tuple Fields
0: String
Implementations
Returns the resource location of the texture, or None
if the texture
should instead take on the value of another texture variable.
Example
let texture = Texture::from("texture/location");
assert_eq!(texture.location(), Some("texture/location"));
let texture = Texture::from("#another_var");
assert_eq!(texture.location(), None);
Returns the name of the texture variable from which this texture should
get its value, or None
if the texture should be loaded from a
resource.
Example
let texture = Texture::from("texture/location");
assert_eq!(texture.reference(), None);
let texture = Texture::from("#another_var");
assert_eq!(texture.reference(), Some("another_var"));
Resolves this texture value using the variables present in other
, or
returns None
if:
- This texture value not reference another texture variable, or
- There is no variable in
other
that matches
Example
use maplit::hashmap;
let substitutions = Textures::from(hashmap! {
"foo" => "textures/foo",
"bar" => "#another_var",
});
let texture = Texture::from("#foo");
assert_eq!(texture.resolve(&substitutions), Some("textures/foo"));
let texture = Texture::from("#bar");
assert_eq!(texture.resolve(&substitutions), Some("#another_var"));
let texture = Texture::from("#not_found");
assert_eq!(texture.resolve(&substitutions), None);
let texture = Texture::from("not_a_reference");
assert_eq!(texture.resolve(&substitutions), None);
Trait Implementations
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
Auto Trait Implementations
impl RefUnwindSafe for Texture
impl UnwindSafe for Texture
Blanket Implementations
Mutably borrows from an owned value. Read more