Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.85 KB | None | 0 0
  1. fn test_save() {
  2.         let mut snapshot = Snapshot::new(Path::new("/tmp/snap.fcs")).unwrap();
  3.         let p = Test_v1 {
  4.             field1: 10,
  5.             field2: "Andrei".to_owned(),
  6.             field3: vec![1; 3],
  7.         };
  8.  
  9.         println!("Saving struct as {:?}", &p);
  10.  
  11.         snapshot.store_object("test_object".to_owned(), 1, &p);
  12.         snapshot.save(1, "Testing".to_owned()).unwrap();
  13.  
  14.         snapshot = Snapshot::load(Path::new("/tmp/snap.fcs")).unwrap();
  15.         let x: Test_v3 = snapshot.restore_object("test_object".to_owned());
  16.         let y: Test_v2 = snapshot.restore_object("test_object".to_owned());
  17.         let z: Test_v1 = snapshot.restore_object("test_object".to_owned());
  18.  
  19.         println!("Restore as {:?}", x);
  20.         println!("Restore as {:?}", y);
  21.         println!("Restore as {:?}", z);
  22.  
  23.         assert!(false);
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement