Skip to main content

FileSource

Trait FileSource 

Source
pub trait FileSource {
    // Required methods
    fn read_file(&self, path: &Path) -> Result<String>;
    fn list_leo_files(&self, dir: &Path, exclude: &Path) -> Result<Vec<PathBuf>>;
}
Expand description

Abstraction over where the compiler reads source files from.

The default implementation DiskFileSource reads from the real filesystem. Alternative implementations enable compilation and formatting from in-memory buffers without requiring disk I/O.

§Path contract

Callers must provide consistent paths. Path normalization is the caller’s responsibility.

§Ordering

FileSource::list_leo_files must return paths in deterministic, sorted order to ensure reproducible module ordering.

Required Methods§

Source

fn read_file(&self, path: &Path) -> Result<String>

Read the contents of a file at the given path.

Source

fn list_leo_files(&self, dir: &Path, exclude: &Path) -> Result<Vec<PathBuf>>

List all .leo files under dir, excluding exclude.

Implementors§