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
pub fn applies<'a, I>(&self, state_values: I) -> bool where
I: IntoIterator<Item = (&'a str, &'a StateValue)>,
pub fn applies<'a, I>(&self, state_values: I) -> bool where
I: IntoIterator<Item = (&'a str, &'a StateValue)>,
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
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 Condition
impl UnwindSafe for Condition
Blanket Implementations
Mutably borrows from an owned value. Read more