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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.