[−][src]Trait sled_extensions::DbExt
Extensions for the sled Db type that provides different ways of opening trees for storing structured data.
Example:
use sled_extensions::{ConfigBuilder, Db, DbExt}; let db = Db::start(ConfigBuilder::default().temporary(true).build())?; let tree = db.open_json_tree::<()>("json-tree")?;
Required methods
fn open_expiring_tree<V, E, F>(&self, name: &str) -> TreeBuilder<V, E, F> where
E: Encoding<HashSet<IVec>> + Encoding<DateTime<Utc>> + 'static,
F: Encoding<V> + 'static,
E: Encoding<HashSet<IVec>> + Encoding<DateTime<Utc>> + 'static,
F: Encoding<V> + 'static,
Open an expiring tree
Expiring trees are trees that keep track of insert and update times in order to help cache implementations. While this library on it's own doesn't provide a fully-featured cache, implementing a cache on top of an expiring tree is simple.
This tree can have numerous types, for example,
use sled_extensions::{ConfigBuilder, Db, DbExt, bincode, cbor, json}; let tree: bincode::expiring::Tree<()> = db.open_expiring_tree("bincode-tree").build()?; let tree: cbor::expiring::Tree<()> = db.open_expiring_tree("cbor-tree").build()?; let tree: json::expiring::Tree<()> = db.open_expiring_tree("json-tree").build()?;
While it is possible to use only this method to open many kinds of expiring trees, it may be easier to use a more specific tree opening method.
fn open_structured_tree<V, E>(&self, name: &str) -> Result<Tree<V, E>> where
E: Encoding<V> + 'static,
E: Encoding<V> + 'static,
Open a structured tree
Structured trees are a thin wrapper on top of basic sled trees that provides encoding and decoding for the data stored in the tree.
This tree can have numerous types, for example,
use sled_extensions::{ConfigBuilder, Db, DbExt, bincode, cbor, json}; let tree: bincode::Tree<()> = db.open_structured_tree("bincode-tree")?; let tree: cbor::Tree<()> = db.open_structured_tree("cbor-tree")?; let tree: json::Tree<()> = db.open_structured_tree("json-tree")?;
While it is possible to use only this method to open many kinds of structured trees, it may be easier to use a more specific tree opening method.
Provided methods
fn open_expiring_structured_tree<V, E>(&self, name: &str) -> TreeBuilder<V, E> where
E: Encoding<V> + Encoding<HashSet<IVec>> + Encoding<DateTime<Utc>> + 'static,
V: DeserializeOwned + Serialize + 'static,
E: Encoding<V> + Encoding<HashSet<IVec>> + Encoding<DateTime<Utc>> + 'static,
V: DeserializeOwned + Serialize + 'static,
Open an expiring tree using an encoding for both metadata storage and value storage
fn open_expiring_plain_tree<E>(&self, name: &str) -> TreeBuilder<E> where
E: Encoding<HashSet<IVec>> + Encoding<DateTime<Utc>> + 'static,
E: Encoding<HashSet<IVec>> + Encoding<DateTime<Utc>> + 'static,
Open an expiring tree using an encoding for metadata storage