Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 2.02 KB | None | 0 0
  1. // File fenerated by Snapshot 0.0.1
  2. // DO NOT EDIT!
  3. // Number of structs: 3
  4. // 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 }) }]] }
  5. impl Snapshotable for Test_v3 {
  6.     fn snapshot(&self, id: String, version: u16, snapshot: &mut Snapshot) {
  7.         match version {
  8.             3 => {
  9.                 // attributes = []
  10.                 snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "field1", 3, &self.field1);
  11.                 // attributes = []
  12.                 snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "field2", 3, &self.field2);
  13.                 // attributes = [SnapshotFieldAttr { name: "default", value: Bool(LitBool { value: true }) }]
  14.                 snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "is_cool", 3, &self.is_cool);
  15.             }
  16.             2 => {
  17.                 // attributes = []
  18.                 snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "field1", 2, &self.field1);
  19.                 // attributes = []
  20.                 snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "field2", 2, &self.field2);
  21.             }
  22.             1 => {
  23.                 // attributes = []
  24.                 snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "field1", 1, &self.field1);
  25.                 // attributes = []
  26.                 snapshot.set_object(SnapshotPropKind::CONFIG, id.clone() + "field2", 1, &self.field2);
  27.             }
  28.         }
  29.     }
  30.     fn restore(id: String, snapshot: &mut Snapshot) -> Self {
  31.          Test_v3 {
  32.             field1: snapshot.get_object(SnapshotPropKind::CONFIG, id.clone() + "field1").unwrap_or_default(),
  33.             field2: snapshot.get_object(SnapshotPropKind::CONFIG, id.clone() + "field2").unwrap_or_default(),
  34.             is_cool: snapshot.get_object(SnapshotPropKind::CONFIG, id.clone() + "is_cool").unwrap_or_default(),
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement