Trait Storage

Source
pub trait Storage:
    Send
    + Sync
    + 'static {
    // Required methods
    fn create<'life0, 'async_trait>(
        storage_directory: &'life0 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
       where 'life0: 'async_trait;
    fn open<'life0, 'async_trait>(
        storage_directory: &'life0 str,
    ) -> Pin<Box<dyn Future<Output = Result<Self, StorageError>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait;
    fn list_files<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn add_or_overwrite_file<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        name: &'life1 str,
        content: String,
    ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn read_file<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<String, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn remove_file<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn remove_all_files<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

An abstraction of the synchronized storage backed by the host file system.

Required Methods§

Source

fn create<'life0, 'async_trait>( storage_directory: &'life0 str, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait,

Creates a new and empty directory. If the directory already exists, removes and re-creates the directory.

Source

fn open<'life0, 'async_trait>( storage_directory: &'life0 str, ) -> Pin<Box<dyn Future<Output = Result<Self, StorageError>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, 'life0: 'async_trait,

Opens an existing directory, locking it.

Source

fn list_files<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Shows the list of files.

Source

fn add_or_overwrite_file<'life0, 'life1, 'async_trait>( &'life0 mut self, name: &'life1 str, content: String, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Adds the given file to the storage.

Source

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

Reads the given file.

Source

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

Removes the given file.

Source

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

Removes all files.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§