Skip to main content

SessionFileSystem

Trait SessionFileSystem 

Source
pub trait SessionFileSystem: Send + Sync {
    // Required methods
    fn read_file<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: SessionId,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<SessionFile>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn write_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        session_id: SessionId,
        path: &'life1 str,
        content: &'life2 str,
        encoding: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = Result<SessionFile>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn delete_file<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: SessionId,
        path: &'life1 str,
        recursive: bool,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_directory<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: SessionId,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<FileInfo>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn stat_file<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: SessionId,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<FileStat>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn grep_files<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        session_id: SessionId,
        pattern: &'life1 str,
        path_pattern: Option<&'life2 str>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<GrepMatch>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn create_directory<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: SessionId,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<FileInfo>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn write_file_if_content_matches<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
        &'life0 self,
        session_id: SessionId,
        path: &'life1 str,
        expected_content: &'life2 str,
        expected_encoding: &'life3 str,
        content: &'life4 str,
        encoding: &'life5 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<SessionFile>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             'life5: 'async_trait { ... }
    fn seed_initial_file<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: SessionId,
        file: &'life1 InitialFile,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Trait for session filesystem operations

This trait abstracts the session filesystem contract for tools and hosts. Implementations can:

  • Store files in a database (production)
  • Use an in-memory filesystem for testing
  • Project files onto real disk or object storage

Required Methods§

Source

fn read_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<SessionFile>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read a file by path

Source

fn write_file<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, content: &'life2 str, encoding: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<SessionFile>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Write/create a file

Source

fn delete_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, recursive: bool, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a file or directory

Source

fn list_directory<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<FileInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List files in a directory

Source

fn stat_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<FileStat>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get file metadata

Source

fn grep_files<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: SessionId, pattern: &'life1 str, path_pattern: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<GrepMatch>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Search files by pattern (grep)

Source

fn create_directory<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<FileInfo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a directory

Provided Methods§

Source

fn write_file_if_content_matches<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, expected_content: &'life2 str, expected_encoding: &'life3 str, content: &'life4 str, encoding: &'life5 str, ) -> Pin<Box<dyn Future<Output = Result<Option<SessionFile>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Write a file only if its current content snapshot still matches.

Implementations backed by transactional storage should override this with an atomic compare-and-set update.

Source

fn seed_initial_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, file: &'life1 InitialFile, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Seed a starter file into a session workspace.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: SessionFileSystem + ?Sized> SessionFileSystem for Arc<T>

Source§

fn read_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<SessionFile>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn write_file<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, content: &'life2 str, encoding: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<SessionFile>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Source§

fn write_file_if_content_matches<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, expected_content: &'life2 str, expected_encoding: &'life3 str, content: &'life4 str, encoding: &'life5 str, ) -> Pin<Box<dyn Future<Output = Result<Option<SessionFile>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Source§

fn delete_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, recursive: bool, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn list_directory<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<FileInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn stat_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<FileStat>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn grep_files<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: SessionId, pattern: &'life1 str, path_pattern: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<GrepMatch>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

fn create_directory<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<FileInfo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn seed_initial_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, file: &'life1 InitialFile, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§