1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! This is the documentation for `savefile`
//!
//! # Introduction
//!
//! Savefile is a rust library to conveniently, quickly and correctly
//! serialize and deserialize arbitrary rust struct and enums into
//! an efficient and compact binary version controlled format.
//!
//! The design use case is any application that needs to save large
//! amounts of data to disk, and support loading files from previous
//! versions of the program (but not from later versions!).
//!
//!
//! # Example
//!
//! ```
//! extern crate savefile;
//! use savefile::prelude::*;
//!
//! #[macro_use]
//! extern crate savefile_derive;
//! use std::fs::File;
//! use std::io::prelude::*;
//!
//!
//! #[derive(WithSchema,Serialize,Deserialize)]
//! struct Player {
//! name : String,
//! strength : u32,
//! inventory : Vec<String>,
//! }
//!
//! fn save(player:&Player) {
//! let mut f = File::create("save.bin").unwrap();
//! Serializer::store(&mut f, 0, player);
//! }
//!
//! fn load() -> Player {
//! let mut f = File::open("save.bin").unwrap();
//! Deserializer::fetch(&mut f, 0)
//! }
//!
//! fn main() {
//! save(&Player { name: "Steve".to_string(), strength: 42,
//! inventory: vec!(
//! "wallet".to_string(),
//! "car keys".to_string(),
//! "glasses".to_string())});
//! assert_eq!(load().name,"Steve".to_string());
//!
//! }
//!
//! ```
//!