pub trait FileSystem: Send + Sync {
// Required methods
fn write_file(&self, path: &str, content: &[u8]) -> Result<()>;
fn read_file(&self, path: &str) -> Result<Vec<u8>>;
// Provided method
fn walk(&self, dir: &str) -> Result<Vec<String>> { ... }
}Expand description
Ported from the subset of sigs.k8s.io/kustomize/kyaml/filesys. FileSystem that Client::build needs: WriteFile/ReadFile (for
test fixtures to populate a hermetic directory tree) plus walk,
which this port adds so Client::build can enumerate every file
under a directory to stage it onto real disk before invoking the
real kustomize binary. walk defaults to “unsupported” so
existing FileSystem implementors elsewhere in the workspace (which
predate this method) keep compiling without needing to implement it
themselves; an implementor that wants its fixtures to exercise real
generator/replacement builds through Client::build must override
it.
Required Methods§
fn write_file(&self, path: &str, content: &[u8]) -> Result<()>
fn read_file(&self, path: &str) -> Result<Vec<u8>>
Provided Methods§
Sourcefn walk(&self, dir: &str) -> Result<Vec<String>>
fn walk(&self, dir: &str) -> Result<Vec<String>>
Returns every file path under dir, recursively. The default
implementation reports “unsupported”: a FileSystem without a
real walk cannot be staged onto disk, so any Client::build
call against it fails with KustomizeError::BuildFailed
rather than silently building an empty directory.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".