FileSystemReader

Trait FileSystemReader 

Source
pub trait FileSystemReader:
    Environment
    + Send
    + Sync {
    // Required methods
    fn ReadFile<'life0, 'life1, 'async_trait>(
        &'life0 self,
        Path: &'life1 PathBuf,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn StatFile<'life0, 'life1, 'async_trait>(
        &'life0 self,
        Path: &'life1 PathBuf,
    ) -> Pin<Box<dyn Future<Output = Result<FileSystemStatDTO, CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn ReadDirectory<'life0, 'life1, 'async_trait>(
        &'life0 self,
        Path: &'life1 PathBuf,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, FileTypeDTO)>, CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

An abstract service contract for an environment component that can perform read-only filesystem operations.

This trait is implemented by MountainEnvironment and typically uses tokio::fs to fulfill the contract. Separating read operations from write operations allows for more granular and secure dependency injection, as some parts of the application may only need read access.

Required Methods§

Source

fn ReadFile<'life0, 'life1, 'async_trait>( &'life0 self, Path: &'life1 PathBuf, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reads the entire content of a file into a byte vector.

§Parameters
  • Path: The PathBuf of the file to read.
§Returns

A Result containing the file’s content as Vec<u8>.

Source

fn StatFile<'life0, 'life1, 'async_trait>( &'life0 self, Path: &'life1 PathBuf, ) -> Pin<Box<dyn Future<Output = Result<FileSystemStatDTO, CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reads metadata for a file or directory.

§Parameters
  • Path: The PathBuf of the file or directory to stat.
§Returns

A Result containing the FileSystemStatDTO metadata.

Source

fn ReadDirectory<'life0, 'life1, 'async_trait>( &'life0 self, Path: &'life1 PathBuf, ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, FileTypeDTO)>, CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reads the entries of a directory.

§Parameters
  • Path: The PathBuf of the directory to read.
§Returns

A Result containing a vector of tuples, where each tuple is (entry_name, entry_file_type).

Implementors§