macro_rules! store {
($type:ident) => { ... };
($type:ident {
values: [$($value:ident),* $(,)?],
parts: [$($part:ident),* $(,)?],
built: [$($built:ident),* $(,)?] $(,)?
}) => { ... };
}Expand description
Implements Store for a type. store!(Type) saves the whole value
through serde. With fields, values are saved through serde, parts save themselves, and built
are kept as construction left them, and every field is named, so one added later doesn’t compile
until it’s placed. A value derives serde::Serialize and serde::Deserialize, and a part
implements Store itself, often with this.
use rigless::snapshot::Store;
/// The bytes a model sent, saved whole.
#[derive(Debug, serde::Serialize, serde::Deserialize)]
struct Sent(Vec<u8>);
rigless::store!(Sent);
/// A model: the bytes it sent are its own state, and its table is what construction built.
struct Beacon { sent: Sent, frames: u32, table: &'static [u8] }
rigless::store!(Beacon { values: [frames], parts: [sent], built: [table] });
fn kept<T: Store>() {}
kept::<Beacon>();