Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // File fenerated by Snapshot 0.0.1
- // DO NOT EDIT!
- // Number of structs: 3
- // StructDescriptor { ty: "Test_v3", version: 3, fields: ["field1", "field2", "is_cool"], field_types: ["u32", "String", "bool"], field_attrs: [[], [], [SnapshotFieldAttr { name: "default", value: Bool(LitBool { value: true }) }]] }
- impl Snapshotable for Test_v3 {
- fn snapshot(&self, id: String, version: u16, snapshot: &mut Snapshot) {
- match version {
- 3 => {
- // attributes = []
- snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "field1", 3, &self.field1);
- // attributes = []
- snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "field2", 3, &self.field2);
- // attributes = [SnapshotFieldAttr { name: "default", value: Bool(LitBool { value: true }) }]
- snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "is_cool", 3, &self.is_cool);
- }
- 2 => {
- // attributes = []
- snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "field1", 2, &self.field1);
- // attributes = []
- snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "field2", 2, &self.field2);
- }
- 1 => {
- // attributes = []
- snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "field1", 1, &self.field1);
- // attributes = []
- snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "field2", 1, &self.field2);
- }
- }
- }
- fn restore(id: String, snapshot: &mut Snapshot) -> Self {
- Test_v3 {
- field1: snapshot.get_object(SnapshotPropKind::CONFIG, id.clone() + "field1").unwrap_or_default(),
- field2: snapshot.get_object(SnapshotPropKind::CONFIG, id.clone() + "field2").unwrap_or_default(),
- is_cool: snapshot.get_object(SnapshotPropKind::CONFIG, id.clone() + "is_cool").unwrap_or_default(),
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement