pub struct Bucket<'a, K: Key<'a>, V: Value>(/* private fields */);
Expand description
Provides typed access to the key/value store
Implementations§
source§impl<'a, K: Key<'a>, V: Value> Bucket<'a, K, V>
impl<'a, K: Key<'a>, V: Value> Bucket<'a, K, V>
sourcepub fn contains(&self, key: &K) -> Result<bool, Error>
pub fn contains(&self, key: &K) -> Result<bool, Error>
Returns true if the bucket contains the given key
sourcepub fn get(&self, key: &K) -> Result<Option<V>, Error>
pub fn get(&self, key: &K) -> Result<Option<V>, Error>
Get the value associated with the specified key
sourcepub fn set(&self, key: &K, value: &V) -> Result<Option<V>, Error>
pub fn set(&self, key: &K, value: &V) -> Result<Option<V>, Error>
Set the value associated with the specified key to the provided value
sourcepub fn compare_and_swap(
&self,
key: &K,
old: Option<&V>,
value: Option<&V>
) -> Result<(), Error>
pub fn compare_and_swap( &self, key: &K, old: Option<&V>, value: Option<&V> ) -> Result<(), Error>
Set the value associated with the specified key to the provided value, only if the existing
value matches the old
parameter
sourcepub fn remove(&self, key: &K) -> Result<Option<V>, Error>
pub fn remove(&self, key: &K) -> Result<Option<V>, Error>
Remove the value associated with the specified key from the database
sourcepub fn iter_range(&self, a: &K, b: &K) -> Result<Iter<K, V>, Error>
pub fn iter_range(&self, a: &K, b: &K) -> Result<Iter<K, V>, Error>
Get an iterator over keys/values in the specified range
sourcepub fn iter_prefix(&self, a: &K) -> Result<Iter<K, V>, Error>
pub fn iter_prefix(&self, a: &K) -> Result<Iter<K, V>, Error>
Iterate over keys/values with the specified prefix
sourcepub fn watch_prefix(&self, prefix: Option<&K>) -> Result<Watch<K, V>, Error>
pub fn watch_prefix(&self, prefix: Option<&K>) -> Result<Watch<K, V>, Error>
Get updates when a key with the given prefix is changed
sourcepub fn transaction<A, E: From<Error>, F: Fn(Transaction<'_, '_, K, V>) -> Result<A, TransactionError<E>>>(
&self,
f: F
) -> Result<A, E>
pub fn transaction<A, E: From<Error>, F: Fn(Transaction<'_, '_, K, V>) -> Result<A, TransactionError<E>>>( &self, f: F ) -> Result<A, E>
Execute a transaction
sourcepub fn transaction2<A, T: Key<'a>, U: Value, E: From<Error>, F: Fn(Transaction<'_, '_, K, V>, Transaction<'_, '_, T, U>) -> Result<A, TransactionError<E>>>(
&self,
other: &Bucket<'a, T, U>,
f: F
) -> Result<A, E>
pub fn transaction2<A, T: Key<'a>, U: Value, E: From<Error>, F: Fn(Transaction<'_, '_, K, V>, Transaction<'_, '_, T, U>) -> Result<A, TransactionError<E>>>( &self, other: &Bucket<'a, T, U>, f: F ) -> Result<A, E>
Create a transaction with access to two buckets
sourcepub fn transaction3<A, T: Key<'a>, U: Value, X: Key<'a>, Y: Value, E: From<Error>, F: Fn(Transaction<'_, '_, K, V>, Transaction<'_, '_, T, U>, Transaction<'_, '_, X, Y>) -> Result<A, TransactionError<E>>>(
&self,
other: &Bucket<'a, T, U>,
other1: &Bucket<'a, X, Y>,
f: F
) -> Result<A, E>
pub fn transaction3<A, T: Key<'a>, U: Value, X: Key<'a>, Y: Value, E: From<Error>, F: Fn(Transaction<'_, '_, K, V>, Transaction<'_, '_, T, U>, Transaction<'_, '_, X, Y>) -> Result<A, TransactionError<E>>>( &self, other: &Bucket<'a, T, U>, other1: &Bucket<'a, X, Y>, f: F ) -> Result<A, E>
Create a transaction with access to three buckets
sourcepub fn prev_key(&self, key: &K) -> Result<Option<Item<K, V>>, Error>
pub fn prev_key(&self, key: &K) -> Result<Option<Item<K, V>>, Error>
Get previous key and value in order, if one exists
sourcepub fn next_key(&self, key: &K) -> Result<Option<Item<K, V>>, Error>
pub fn next_key(&self, key: &K) -> Result<Option<Item<K, V>>, Error>
Get next key and value in order, if one exists
sourcepub async fn flush_async(&self) -> Result<usize, Error>
pub async fn flush_async(&self) -> Result<usize, Error>
Flush to disk