Skip to main content

value_model

Macro value_model 

Source
macro_rules! value_model {
    (default: $($ty:ty),* $(,)?) => { ... };
    ($($ty:ty),* $(,)?) => { ... };
}
Expand description

Implements Model (and Settable) for serde types stored as their JSON form, the way a serde_json::Value is: an object as a map, an array as a list, everything else as a scalar. For a type #[derive(Model)] cannot describe: one defined in a crate below this one (an ActionKey), or one that holds itself (a condition made of conditions). A type the app shapes derives Model instead, so its fields have paths and edits of their own.

The types need Serialize, Deserialize and a PartialEq holding only between values of equal JSON forms, as a derived one does. An absent slot has no value: hold one in an Option, a Vec or a map, or name the types after default: to read an absent slot as their Default.