Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend: Send + Sync {
    // Required methods
    fn store(
        &self,
        id: &str,
        data: &[u8],
        metadata: &FileMetadata,
    ) -> Result<FileInfo, String>;
    fn retrieve(&self, id: &str) -> Result<Vec<u8>, String>;
    fn delete(&self, id: &str) -> Result<bool, String>;
    fn exists(&self, id: &str) -> bool;
    fn metadata(&self, id: &str) -> Option<FileMetadata>;
    fn list(&self) -> Vec<String>;
}
Expand description

Abstraction over file storage backends (local disk, S3, GCS, etc.).

Required Methods§

Source

fn store( &self, id: &str, data: &[u8], metadata: &FileMetadata, ) -> Result<FileInfo, String>

Store data under the given ID with associated metadata.

Source

fn retrieve(&self, id: &str) -> Result<Vec<u8>, String>

Retrieve the raw bytes for a stored file.

Source

fn delete(&self, id: &str) -> Result<bool, String>

Delete a stored file. Returns true if the file existed and was removed.

Source

fn exists(&self, id: &str) -> bool

Check whether a file exists.

Source

fn metadata(&self, id: &str) -> Option<FileMetadata>

Retrieve metadata for a stored file, if it exists.

Source

fn list(&self) -> Vec<String>

List all stored file IDs.

Implementors§