Skip to main content

StorageService

Trait StorageService 

Source
pub trait StorageService: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn upload<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        data: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn download<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Bytes, StorageError>> + 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 = Result<(), StorageError>> + 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 = Result<bool, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn url<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        expires_in: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<Url, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Shared trait implemented by each storage backend.

Required Methods§

Source

fn name(&self) -> &str

Returns the configured service name.

Source

fn upload<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, data: Bytes, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Uploads a new object.

§Errors

Returns an error when the key already exists or the backend write fails.

Source

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

Downloads an existing object.

§Errors

Returns an error when the key does not exist or the backend read fails.

Source

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

Deletes an object if it exists.

§Errors

Returns an error when the backend delete fails.

Source

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

Returns whether the object exists.

§Errors

Returns an error when the backend existence check fails unexpectedly.

Source

fn url<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, expires_in: Duration, ) -> Pin<Box<dyn Future<Output = Result<Url, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Generates a download URL.

§Errors

Returns an error when the URL cannot be generated.

Implementors§