Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend: Send + Sync {
    // Required methods
    fn put(&self, key: &str, data: &[u8]) -> Result<()>;
    fn get(&self, key: &str) -> Result<Vec<u8>>;
    fn delete(&self, key: &str) -> Result<()>;
    fn exists(&self, key: &str) -> Result<bool>;
    fn list(&self, prefix: &str) -> Result<Vec<ObjectMetadata>>;
    fn sync(&self) -> Result<()>;
    fn base_path(&self) -> Option<&Path>;
}
Expand description

Storage backend trait

Abstracts storage operations to support multiple backends:

  • LocalFsBackend: Local filesystem (default)
  • S3Backend: AWS S3 (planned)
  • GcsBackend: Google Cloud Storage (planned)
  • AzureBlobBackend: Azure Blob Storage (planned)

Usage:

let backend = LocalFsBackend::new("/data")?;
backend.put("wal.log", &data)?;
let data = backend.get("wal.log")?;

Required Methods§

Source

fn put(&self, key: &str, data: &[u8]) -> Result<()>

Write data to a key

Source

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

Read data from a key

Source

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

Delete a key

Source

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

Check if a key exists

Source

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

List all keys with a prefix

Source

fn sync(&self) -> Result<()>

Sync/flush data to durable storage

Source

fn base_path(&self) -> Option<&Path>

Get the base path for this backend (if applicable)

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§