Struct minecraft_assets::schemas::blockstates::multipart::Condition[][src]

pub struct Condition {
    pub and: HashMap<String, StateValue>,
}
Expand description

A set of conditions that all have to match the block to return true.

The condition is structured as a map from state to value, so for instance:

"when": {"north": "side|up", "east": "side|up" }

Fields

and: HashMap<String, StateValue>

Map from state name to state value that forms the list of conditions.

Implementations

Returns true if

Example
use maplit::hashmap;

let condition = Condition {
    and: hashmap! {
        String::from("var1") => StateValue::from("foo|bar"),
        String::from("var2") => StateValue::from(false),
    },
};

let foo_string = StateValue::from("foo");
let other_string = StateValue::from("other");
let true_string = StateValue::from("true");
let false_string = StateValue::from("false");

let state_values = vec![
    ("var1", &foo_string),
    ("var2", &false_string),
    ("var3", &true_string),
];
assert!(condition.applies(state_values.into_iter()));

let state_values = vec![
    ("var2", &false_string),
];
assert!(!condition.applies(state_values.into_iter()));

let state_values = vec![
    ("var1", &other_string),
    ("var2", &false_string),
];
assert!(!condition.applies(state_values.into_iter()));

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

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.