Struct Database

Source
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

Source

pub fn new(path: PathBuf, passphrase: &[u8]) -> Result<Self, DatabaseOpenError>

Opens a new Database instance.

Source

pub fn temporary() -> Result<Self, DatabaseOpenError>

Opens a new temporary Database instance

Source

pub fn set_passphrase( &self, passphrase: &[u8], ) -> Result<(), DatabaseSetPassphraseError>

Source

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

Source

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.

Source

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.

Source

pub fn keys(&self) -> impl DoubleEndedIterator<Item = Result<IVec>>

Iterate over all keys in the database

Source

pub fn encryption_key(&self) -> &Key

Get encryption key

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.