Skip to main content

FileBackend

Trait FileBackend 

Source
pub trait FileBackend: Send + Sync {
    // Required methods
    fn read<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        number: bool,
        start_line: i32,
        end_line: i32,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn write<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        content: &'life2 str,
        start_line: i32,
        end_line: i32,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn search<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        root: &'life1 str,
        pattern: &'life2 str,
        limit: i32,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn list<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn tree<'life0, 'life1, 'async_trait>(
        &'life0 self,
        root: &'life1 str,
        level: i32,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn context<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn mkdir<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn move_file<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        from: &'life1 str,
        to: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn find<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        root: &'life1 str,
        name: &'life2 str,
        file_type: &'life3 str,
        limit: i32,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

Filesystem backend that tools delegate to.

All paths are workspace-relative (e.g. “contacts/john.md”, not absolute). Implementations handle the actual I/O (RPC, local fs, in-memory mock).

Required Methods§

Source

fn read<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, number: bool, start_line: i32, end_line: i32, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read file contents, optionally with line numbers and range.

  • number: if true, prefix each line with its 1-indexed number (like cat -n)
  • start_line/end_line: 1-indexed range (0 = no limit)
Source

fn write<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 str, content: &'life2 str, start_line: i32, end_line: i32, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Write content to a file, optionally replacing a line range.

  • start_line/end_line: 1-indexed range to replace (0 = overwrite entire file)
Source

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

Delete a file.

Source

fn search<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, root: &'life1 str, pattern: &'life2 str, limit: i32, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Search file contents with regex pattern.

Returns grep-style output: path:line_number:content

Source

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

List directory entries.

Returns one entry per line, directories suffixed with /.

Source

fn tree<'life0, 'life1, 'async_trait>( &'life0 self, root: &'life1 str, level: i32, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Show recursive directory tree.

  • level: max depth (0 = unlimited)
Source

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

Get workspace context (date, time, environment info).

Source

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

Create a directory.

Source

fn move_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, from: &'life1 str, to: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Move or rename a file.

Source

fn find<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, root: &'life1 str, name: &'life2 str, file_type: &'life3 str, limit: i32, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Find files by name pattern.

  • file_type: “files”, “dirs”, or empty for all
  • limit: max results (0 = no limit)

Implementors§