Enum DefaultStorageDB

Source
pub enum DefaultStorageDB {
    Sled(SledStorageDB),
    Redis(RedisStorageDB),
    RedisCluster(RedisStorageDB),
}
Expand description

Unified storage backend enum (dispatches to concrete implementations)

Variants§

§

Sled(SledStorageDB)

Sled database backend

§

Redis(RedisStorageDB)

Redis backend

§

RedisCluster(RedisStorageDB)

Redis Cluster backend

Implementations§

Source§

impl DefaultStorageDB

Source

pub async fn map<V: AsRef<[u8]> + Sync + Send>( &self, name: V, expire: Option<i64>, ) -> Result<StorageMap>

Accesses a named map

Source

pub async fn map_remove<K>(&self, name: K) -> Result<()>
where K: AsRef<[u8]> + Sync + Send,

Removes a named map

Source

pub async fn map_contains_key<K: AsRef<[u8]> + Sync + Send>( &self, key: K, ) -> Result<bool>

Checks if map exists

Source

pub async fn list<V: AsRef<[u8]> + Sync + Send>( &self, name: V, expire: Option<i64>, ) -> Result<StorageList>

Accesses a named list

Source

pub async fn list_remove<K>(&self, name: K) -> Result<()>
where K: AsRef<[u8]> + Sync + Send,

Removes a named list

Source

pub async fn list_contains_key<K: AsRef<[u8]> + Sync + Send>( &self, key: K, ) -> Result<bool>

Checks if list exists

Source

pub async fn insert<K, V>(&self, key: K, val: &V) -> Result<()>
where K: AsRef<[u8]> + Sync + Send, V: Serialize + Sync + Send,

Inserts a key-value pair

Source

pub async fn get<K, V>(&self, key: K) -> Result<Option<V>>
where K: AsRef<[u8]> + Sync + Send, V: DeserializeOwned + Sync + Send,

Retrieves a value by key

Source

pub async fn remove<K>(&self, key: K) -> Result<()>
where K: AsRef<[u8]> + Sync + Send,

Removes a key-value pair

Source

pub async fn batch_insert<V>(&self, key_vals: Vec<(Vec<u8>, V)>) -> Result<()>
where V: Serialize + Sync + Send,

Batch insert of key-value pairs

Source

pub async fn batch_remove(&self, keys: Vec<Vec<u8>>) -> Result<()>

Batch removal of keys

Source

pub async fn counter_incr<K>(&self, key: K, increment: isize) -> Result<()>
where K: AsRef<[u8]> + Sync + Send,

Increments a counter

Source

pub async fn counter_decr<K>(&self, key: K, decrement: isize) -> Result<()>
where K: AsRef<[u8]> + Sync + Send,

Decrements a counter

Source

pub async fn counter_get<K>(&self, key: K) -> Result<Option<isize>>
where K: AsRef<[u8]> + Sync + Send,

Gets counter value

Source

pub async fn counter_set<K>(&self, key: K, val: isize) -> Result<()>
where K: AsRef<[u8]> + Sync + Send,

Sets counter value

Source

pub async fn len(&self) -> Result<usize>

Gets number of items (requires “len” feature)

Source

pub async fn db_size(&self) -> Result<usize>

Gets total storage size in bytes

Source

pub async fn contains_key<K: AsRef<[u8]> + Sync + Send>( &self, key: K, ) -> Result<bool>

Checks if key exists

Source

pub async fn expire_at<K>(&self, key: K, at: i64) -> Result<bool>
where K: AsRef<[u8]> + Sync + Send,

Sets expiration timestamp (requires “ttl” feature)

Source

pub async fn expire<K>(&self, key: K, dur: i64) -> Result<bool>
where K: AsRef<[u8]> + Sync + Send,

Sets expiration duration (requires “ttl” feature)

Source

pub async fn ttl<K>(&self, key: K) -> Result<Option<i64>>
where K: AsRef<[u8]> + Sync + Send,

Gets time-to-live (requires “ttl” feature)

Source

pub async fn map_iter<'a>( &'a mut self, ) -> Result<Box<dyn AsyncIterator<Item = Result<StorageMap>> + Send + 'a>>

Iterates over maps

Source

pub async fn list_iter<'a>( &'a mut self, ) -> Result<Box<dyn AsyncIterator<Item = Result<StorageList>> + Send + 'a>>

Iterates over lists

Source

pub async fn scan<'a, P>( &'a mut self, pattern: P, ) -> Result<Box<dyn AsyncIterator<Item = Result<Vec<u8>>> + Send + 'a>>
where P: AsRef<[u8]> + Send + Sync,

Scans keys matching pattern

Source

pub async fn info(&self) -> Result<Value>

Gets storage information

Trait Implementations§

Source§

impl Clone for DefaultStorageDB

Source§

fn clone(&self) -> DefaultStorageDB

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,