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§
Sourcefn store(
&self,
id: &str,
data: &[u8],
metadata: &FileMetadata,
) -> Result<FileInfo, String>
fn store( &self, id: &str, data: &[u8], metadata: &FileMetadata, ) -> Result<FileInfo, String>
Store data under the given ID with associated metadata.
Sourcefn retrieve(&self, id: &str) -> Result<Vec<u8>, String>
fn retrieve(&self, id: &str) -> Result<Vec<u8>, String>
Retrieve the raw bytes for a stored file.
Sourcefn delete(&self, id: &str) -> Result<bool, String>
fn delete(&self, id: &str) -> Result<bool, String>
Delete a stored file. Returns true if the file existed and was removed.
Sourcefn metadata(&self, id: &str) -> Option<FileMetadata>
fn metadata(&self, id: &str) -> Option<FileMetadata>
Retrieve metadata for a stored file, if it exists.