Skip to main content

FileSource

Trait FileSource 

Source
pub trait FileSource {
    // Required methods
    fn read_file(&self, path: &Path) -> Result<String, Error>;
    fn list_leo_files(
        &self,
        dir: &Path,
        exclude: &Path,
    ) -> Result<Vec<PathBuf>, Error>;
}
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, Error>

Read the contents of a file at the given path.

Source

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

List all .leo files under dir, excluding exclude.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§