FileProvider

Trait FileProvider 

Source
pub trait FileProvider: Send + Sync {
    // Required methods
    fn get(&self, path: &str) -> Result<Vec<u8>>;
    fn exists(&self, path: &str) -> bool;
    fn glob(&self, pattern: &str) -> Result<Vec<FileEntry>>;
    fn lines(&self, path: &str) -> Result<Vec<String>>;

    // Provided method
    fn get_string(&self, path: &str) -> Result<String> { ... }
}
Expand description

Trait for file access providers

This trait allows for different implementations:

  • SandboxedFileProvider: Real filesystem access (sandboxed to pack root)
  • MockFileProvider: In-memory files for testing
  • ArchiveFileProvider: Read files from a tar.gz archive (future)

Required Methods§

Source

fn get(&self, path: &str) -> Result<Vec<u8>>

Read the contents of a file as bytes

Source

fn exists(&self, path: &str) -> bool

Check if a file exists

Source

fn glob(&self, pattern: &str) -> Result<Vec<FileEntry>>

List files matching a glob pattern

Source

fn lines(&self, path: &str) -> Result<Vec<String>>

Read a file as lines

Provided Methods§

Source

fn get_string(&self, path: &str) -> Result<String>

Read the contents of a file as a string (UTF-8)

Implementors§