pub trait FileSystem: Send + Sync {
Show 18 methods
// Required methods
fn cwd(&self) -> &Path;
fn absolute_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn join_path<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
parts: &'life1 [&'life2 str],
cancel: Option<&'life3 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn read_text_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<String, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn read_text_lines<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
max_lines: Option<usize>,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn read_binary_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn write_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
content: FileContent,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn append_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
content: FileContent,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn rename_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
source: &'life1 str,
dest: &'life2 str,
cancel: Option<&'life3 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn file_info<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<FileInfo, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn list_dir<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Vec<FileInfo>, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn canonical_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<bool, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn create_dir<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
recursive: bool,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn remove<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
recursive: bool,
force: bool,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn create_temp_dir<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prefix: Option<&'life1 str>,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn create_temp_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
suffix: &'life2 str,
cancel: Option<&'life3 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn cleanup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Mirrors TS FileSystem. All methods async, never panic.
cancel: Option<&CancellationToken> is the Rust analogue of the optional
abortSignal; backends SHOULD check it at entry (returning
FileError::aborted()) and honor cooperative cancel during long ops.
Required Methods§
Sourcefn absolute_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn absolute_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Resolve path (relative-to-cwd, ~, file://, absolute) to an absolute
addressed path. Pure — no FS access, no abort. Mirrors TS absolutePath.
Sourcefn join_path<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
parts: &'life1 [&'life2 str],
cancel: Option<&'life3 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn join_path<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
parts: &'life1 [&'life2 str],
cancel: Option<&'life3 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Join path components. Pure. Mirrors TS joinPath.
fn read_text_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<String, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn read_text_lines<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
max_lines: Option<usize>,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn read_text_lines<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
max_lines: Option<usize>,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Stream-read up to max_lines lines (split on \n; max_lines <= 0
→ empty). Mirrors TS readTextLines{maxLines}.
fn read_binary_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn write_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
content: FileContent,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn write_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
content: FileContent,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Creates parent directories (recursive) automatically. Mirrors TS
writeFile.
fn append_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
content: FileContent,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn rename_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
source: &'life1 str,
dest: &'life2 str,
cancel: Option<&'life3 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Sourcefn file_info<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<FileInfo, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn file_info<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<FileInfo, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Uses symlink_metadata (lstat — symlinks not followed). Mirrors TS
fileInfo.
fn list_dir<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Vec<FileInfo>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn canonical_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn canonical_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Follows symlinks (canonicalize). Mirrors TS canonicalPath. Backends
may return not_found or not_supported for missing/unsupported paths;
callers (mutation queue) fall back to absolute path on those codes.
Sourcefn exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<bool, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<bool, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
false ONLY for not_found; other errors propagate. Mirrors TS
exists (which delegates to fileInfo, NOT access(F_OK)).
Sourcefn create_dir<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
recursive: bool,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn create_dir<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
recursive: bool,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Default recursive=true. Mirrors TS createDir{recursive}.
Sourcefn remove<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
recursive: bool,
force: bool,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
recursive: bool,
force: bool,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Defaults recursive=false, force=false. Mirrors TS remove.
Sourcefn create_temp_dir<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prefix: Option<&'life1 str>,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn create_temp_dir<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prefix: Option<&'life1 str>,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Default prefix "tmp-". Mirrors TS createTempDir{prefix}.
Sourcefn create_temp_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
suffix: &'life2 str,
cancel: Option<&'life3 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn create_temp_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
suffix: &'life2 str,
cancel: Option<&'life3 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Mirrors TS createTempFile{prefix,suffix} (defaults empty). Note: the
TS impl creates an isolated temp dir per file; backends may simplify
to a single file in the OS temp dir (document any divergence).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".