pub trait Fs {
// Required methods
fn read(&self, path: &Path) -> Result<Vec<u8>>;
fn exists(&self, path: &Path) -> bool;
fn is_dir(&self, path: &Path) -> bool;
fn is_file(&self, path: &Path) -> bool;
fn read_dir(&self, dir: &Path) -> Result<Vec<String>>;
}Expand description
Read/write access to the filesystem — the Fs half of the Fs/Git seam
(ADR-0001 §2). Domain code (contract loading, journal persistence, sealed
plans) goes through this port rather than calling std::fs directly, so it
is testable against an in-memory fake. At founding this is a deliberately
small surface; it grows (atomic writes, dir listing, metadata) as the
journal and plan-sealing units land.
Required Methods§
Sourcefn is_dir(&self, path: &Path) -> bool
fn is_dir(&self, path: &Path) -> bool
Whether path exists and is a directory (used for the contract’s
fragment-dir producer check, which is a directory, not a file).
Sourcefn is_file(&self, path: &Path) -> bool
fn is_file(&self, path: &Path) -> bool
Whether path exists and is a regular file — not a directory, FIFO,
socket, or device (mirrors os.path.isfile). The facts detector gates
every manifest/config read on this so a non-regular node named
Cargo.toml neither marks an ecosystem nor blocks Self::read (a
blocking read on a FIFO is a real hang the exists && !is_dir
approximation would not prevent).
Sourcefn read_dir(&self, dir: &Path) -> Result<Vec<String>>
fn read_dir(&self, dir: &Path) -> Result<Vec<String>>
List the immediate entry names (not full paths) within dir — the
facts detector’s CI probe needs to know whether .github/workflows
holds at least one entry, not merely that the directory exists.
Ok(vec![]) for an empty directory; Err when dir is absent or
unreadable (the detector treats that as “no entries”).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".