pub struct Database { /* private fields */ }
Expand description
A KV store based on sled, storing serde_json::Value values in an encrypted fashion
Implementations§
Source§impl Database
impl Database
Sourcepub fn new(path: PathBuf, passphrase: &[u8]) -> Result<Self, DatabaseOpenError>
pub fn new(path: PathBuf, passphrase: &[u8]) -> Result<Self, DatabaseOpenError>
Opens a new Database instance.
Sourcepub fn temporary() -> Result<Self, DatabaseOpenError>
pub fn temporary() -> Result<Self, DatabaseOpenError>
Opens a new temporary Database instance
pub fn set_passphrase( &self, passphrase: &[u8], ) -> Result<(), DatabaseSetPassphraseError>
Sourcepub fn get(&self, key: &str) -> Result<Option<Value>, DatabaseError>
pub fn get(&self, key: &str) -> Result<Option<Value>, DatabaseError>
Get a serde_json::Value from the database. The wrapping sled::Result will only throw an error when something goes really wrong. The Option inside that Result indicates whether the requested item is present
Sourcepub fn insert(&self, key: &str, value: &Value) -> Result<(), DatabaseError>
pub fn insert(&self, key: &str, value: &Value) -> Result<(), DatabaseError>
Insert a serde_json::Value into the database. The wrapping sled::Result will only throw an error when something goes really wrong. The Option inside contains the ciphertext of the just inserted value, if this insertion was successful.
Sourcepub fn remove(&self, key: &str) -> Result<Option<Value>, DatabaseError>
pub fn remove(&self, key: &str) -> Result<Option<Value>, DatabaseError>
Remove a value from the database. The wrapping sled::Result will only throw an error when something goes really wrong. The Option inside contains the old value, if one was present.
Sourcepub fn keys(&self) -> impl DoubleEndedIterator<Item = Result<IVec>>
pub fn keys(&self) -> impl DoubleEndedIterator<Item = Result<IVec>>
Iterate over all keys in the database
Sourcepub fn encryption_key(&self) -> &Key
pub fn encryption_key(&self) -> &Key
Get encryption key