DataStorage

Trait DataStorage 

Source
pub trait DataStorage {
    // Required methods
    async fn get_keys(&self) -> Result<Vec<String>, DataStorageError>;
    async fn store<T: Serialize>(
        &self,
        key: &str,
        mode: &StoreMode,
        item: &T,
    ) -> Result<(), DataStorageError>;
    async fn get<T: DeserializeOwned>(
        &self,
        key: &str,
    ) -> Result<Option<(T, String)>, DataStorageError>;
    async fn delete(&self, key: &str) -> Result<(), DataStorageError>;
    async fn delete_all(&self) -> Result<(), DataStorageError>;
}
Expand description

A trait for data storage operations that can be implemented by different storage backends.

This trait defines the core interface for data storage operations, allowing implementations to use different storage backends (local, distributed) while providing a consistent API.

Required Methods§

Source

async fn get_keys(&self) -> Result<Vec<String>, DataStorageError>

Returns all keys currently stored in the store.

Source

async fn store<T: Serialize>( &self, key: &str, mode: &StoreMode, item: &T, ) -> Result<(), DataStorageError>

Stores a serializable item for a given key using the provided StoreMode.

Source

async fn get<T: DeserializeOwned>( &self, key: &str, ) -> Result<Option<(T, String)>, DataStorageError>

Retrieves and deserializes the value for a given key, returning the value and its CAS string if present. Returns Ok(None) when the key does not exist.

Source

async fn delete(&self, key: &str) -> Result<(), DataStorageError>

Removes the item identified by the provided key from this storage instance.

Source

async fn delete_all(&self) -> Result<(), DataStorageError>

Removes all items from this storage instance.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§