Skip to main content

FileStorage

Trait FileStorage 

Source
pub trait FileStorage: Send + Sync {
    // Required methods
    fn store<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        path: &'life1 Path,
        content: &'life2 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<StoredFileId>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn retrieve<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 StoredFileId,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 StoredFileId,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn metadata<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 StoredFileId,
    ) -> Pin<Box<dyn Future<Output = Result<StoredFileMetadata>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn exists<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 StoredFileId,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn public_url(&self, _id: &StoredFileId) -> Option<String> { ... }
}
Expand description

Trait for file storage operations

Implementations of this trait handle the actual storage and retrieval of file contents, whether that’s local filesystem, cloud storage, etc.

Required Methods§

Source

fn store<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 Path, content: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<StoredFileId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store a file at the given path with the provided content

Source

fn retrieve<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 StoredFileId, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve the contents of a file by its ID

Source

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

Delete a file by its ID

Source

fn metadata<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 StoredFileId, ) -> Pin<Box<dyn Future<Output = Result<StoredFileMetadata>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get metadata for a file by its ID

Source

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

Check if a file exists by its ID

Provided Methods§

Source

fn public_url(&self, _id: &StoredFileId) -> Option<String>

Get the public URL for a file (if applicable)

Implementors§