Crate automerge_persistent_sled
source ·Expand description
A persister targetting Sled.
Single persister
let db = sled::Config::new().temporary(true).open()?;
let changes_tree = db.open_tree("changes")?;
let documents_tree = db.open_tree("documents")?;
let sync_states_tree = db.open_tree("sync-states")?;
let persister = SledPersister::new(changes_tree, documents_tree, sync_states_tree, "")?;
let doc = PersistentAutomerge::load(persister);
Multiple persisters sharing the same trees
let db = sled::Config::new().temporary(true).open()?;
let changes_tree = db.open_tree("changes")?;
let documents_tree = db.open_tree("documents")?;
let sync_states_tree = db.open_tree("sync-states")?;
let persister1 = SledPersister::new(
changes_tree.clone(),
documents_tree.clone(),
sync_states_tree.clone(),
"1",
)?;
let doc1 = PersistentAutomerge::load(persister1);
let persister2 = SledPersister::new(changes_tree, documents_tree, sync_states_tree, "2")?;
let doc2 = PersistentAutomerge::load(persister2);
Structs
- The persister that stores changes and documents in sled trees.
Enums
- Possible errors from persisting.