Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend: Send + Sync {
    // Required methods
    fn upload<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        data: &'life2 [u8],
        content_type: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = StorageResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn download<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<u8>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn exists<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn presigned_url<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        expiry: Duration,
    ) -> Pin<Box<dyn Future<Output = StorageResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Trait for object storage backends.

Implementations handle file upload, download, deletion, existence checks, and presigned URL generation across different storage providers.

§Errors

All methods return FileError on failure. Common variants:

Required Methods§

Source

fn upload<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, key: &'life1 str, data: &'life2 [u8], content_type: &'life3 str, ) -> Pin<Box<dyn Future<Output = StorageResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Uploads data and returns the storage key.

§Errors

Returns FileError::Storage if the upload fails.

Source

fn download<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Downloads the contents of the given key.

§Errors

Returns FileError::NotFound if the key does not exist, or FileError::Storage on backend errors.

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes the object at the given key.

§Errors

Returns FileError::NotFound if the key does not exist, or FileError::Storage on backend errors.

Source

fn exists<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Checks whether an object exists at the given key.

§Errors

Returns FileError::Storage on backend communication errors.

Source

fn presigned_url<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, expiry: Duration, ) -> Pin<Box<dyn Future<Output = StorageResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Generates a presigned (time-limited) URL for direct access to an object.

§Errors

Returns FileError::Storage if presigned URLs are not supported by the backend or if generation fails.

Implementors§