Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend: Send + Sync {
    // Required methods
    fn list(&self, prefix: &str) -> Result<Vec<String>>;
    fn get(&self, key: &str) -> Result<Bytes>;
    fn put(&self, key: &str, data: Bytes) -> Result<()>;
    fn delete(&self, key: &str) -> Result<()>;
    fn exists(&self, key: &str) -> Result<bool>;
    fn size(&self, key: &str) -> Result<u64>;
}
Expand description

A storage backend for reading and writing data.

Backends abstract the underlying storage mechanism, allowing datasets and registries to work with local files, cloud storage, or in-memory buffers using the same interface.

§Async Design

All operations are synchronous for now (v0.1). Future versions will add async variants behind the tokio-runtime feature flag.

Required Methods§

Source

fn list(&self, prefix: &str) -> Result<Vec<String>>

Lists all keys with the given prefix.

Returns a vector of key names (relative to the backend root).

§Errors

Returns an error if the listing operation fails.

Source

fn get(&self, key: &str) -> Result<Bytes>

Reads data from the given key.

§Errors

Returns an error if the key does not exist or cannot be read.

Source

fn put(&self, key: &str, data: Bytes) -> Result<()>

Writes data to the given key.

Creates parent directories/prefixes as needed.

§Errors

Returns an error if the write fails.

Source

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

Deletes the given key.

§Errors

Returns an error if the key cannot be deleted.

Source

fn exists(&self, key: &str) -> Result<bool>

Checks if the given key exists.

§Errors

Returns an error if the existence check fails.

Source

fn size(&self, key: &str) -> Result<u64>

Returns the size of the data at the given key in bytes.

§Errors

Returns an error if the key does not exist.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§