# checkpoint
Provides checkpointing of application data for the Rust Programming Language.

Please see the [API documentation](https://docs.rs/checkpoint/) for details.

Example Usage:
```rust
// Checkpoint data is serialized and deserialized with the Serde library.
extern crate serde;
#[macro_use] extern crate serde_derive;

use serde::de::DeserializeOwned;
use serde::ser::Serialize;

extern crate checkpoint;

use checkpoint::Result;
use checkpoint::storage::{
    CommittedCheckpoint, Storage, MemoryStorage, UncommittedCheckpoint};
use checkpoint::wrappers::ChecksumWrapper;

// Any type implementing the Serialize and DeserializeOwned traits can be checkpointed.
#[derive(Deserialize, Serialize)]
struct Person {
    name: String,
    age: u8
}

// Create the data that will be stored in a checkpoint.
let person = Person {
    name: String::from("John Smith"),
    age: 50
};

// Create a MemoryStorage object to hold checkpoint data.
let storage = MemoryStorage::new()?;

// Add integrity checks to checkpoint data with a ChecksumWrapper.
let mut wrapped_storage = ChecksumWrapper::wrap(storage);

// Create a new checkpoint.
let mut uncommitted_checkpoint = wrapped_storage.create_checkpoint("Checkpoint")?;

// Add data to the checkpoint.
uncommitted_checkpoint.put("Person", &person)?;

// Commit the checkpoint.
let mut committed_checkpoint = wrapped_storage.commit_checkpoint(uncommitted_checkpoint)?;

// Retrieve the checkpoint data.
let stored_person: Person = committed_checkpoint.get("Person")?;

// The data retrieved from the checkpoint is the same as what was put in.
assert_eq!(person.name, stored_person.name);
assert_eq!(person.age, stored_person.age);
```
