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.
excludeinFileSource::list_leo_filesis compared by exact path equality, so it must match the listed path exactly.InMemoryFileSource::read_fileperforms exact key lookup.
§Ordering
FileSource::list_leo_files must return paths in deterministic, sorted
order to ensure reproducible module ordering.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".