pub trait Filesystem {
// Required methods
fn write_atomic(&self, path: &str, bytes: &[u8]) -> Result<(), FsError>;
fn rename(&self, from: &str, to: &str) -> Result<(), FsError>;
fn remove(&self, path: &str) -> Result<(), FsError>;
fn prune_empty_dirs(&self, root: &str) -> Result<(), FsError>;
fn read(&self, path: &str) -> Result<Vec<u8>, FsError>;
fn metadata(&self, path: &str) -> Option<FileStat>;
}Expand description
The disk port the executor writes the plan through.
Methods are synchronous: disk IO is fast and the adapter can offload it if
it must. Every method returns a Result so the engine never panics on an
IO fault; a write failure must leave any prior file intact (atomic write).
Required Methods§
Sourcefn write_atomic(&self, path: &str, bytes: &[u8]) -> Result<(), FsError>
fn write_atomic(&self, path: &str, bytes: &[u8]) -> Result<(), FsError>
Write bytes to path atomically, replacing any existing file.
On failure the prior file at path is left untouched: the adapter
stages a temporary sibling and renames it into place only once the full
contents are written, so a partial write can never be observed.
Sourcefn rename(&self, from: &str, to: &str) -> Result<(), FsError>
fn rename(&self, from: &str, to: &str) -> Result<(), FsError>
Move from onto to, replacing any existing destination.
Sourcefn remove(&self, path: &str) -> Result<(), FsError>
fn remove(&self, path: &str) -> Result<(), FsError>
Remove path. Succeeds when the file is already absent (idempotent).
Sourcefn prune_empty_dirs(&self, root: &str) -> Result<(), FsError>
fn prune_empty_dirs(&self, root: &str) -> Result<(), FsError>
Remove empty directories under root, bottom-up.
After a rename/move or a delete empties an album directory, that now-dead directory is a ghost. This prunes it. The contract is strictly additive and safe:
- it removes only directories that are genuinely empty, walking depth-first so an emptied parent is pruned once its last child is;
- it NEVER removes a directory holding any entry, including a hidden file
(a
.suno-manifest.json,.suno-lineage.json, or.m3u8); and - it NEVER removes
rootitself, only directories strictly beneath it.
root is a library-relative directory, with the empty string (or ".")
meaning the account root. A prune failure is never fatal: the tool
re-plans and retries on the next run, so this only ever tidies.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".