pub trait FileSystem: Send + Sync {
Show 29 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;
// Provided methods
fn native_file_path(&self, _path: &str) -> Option<PathBuf> { ... }
fn read_text_file_bounded<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
max_bytes: usize,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn write_new_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 open_append_file<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn AppendFile>>, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn try_acquire_writer_lease<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn WriterLease>>, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn sync_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_path: &'life1 str,
_data_only: 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 sync_directory<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_path: &'life1 str,
_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 sync_file_and_parent<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
_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 open_read_file<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Arc<dyn ReadFile>>, FileError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn truncate_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
len: u64,
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 has_file_with_suffix<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
path: &'life1 str,
suffix: &'life2 str,
cancel: Option<&'life3 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,
'life3: 'async_trait { ... }
}Expand description
Mirrors TS FileSystem. All methods async, never panic.
Backends should check cancellation at entry and during long operations.
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 for a missing path or not_supported if they
cannot resolve canonical paths.
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).
Provided Methods§
Sourcefn native_file_path(&self, _path: &str) -> Option<PathBuf>
fn native_file_path(&self, _path: &str) -> Option<PathBuf>
Resolve a host path when this backend explicitly permits native I/O. Abstract and restricted backends do not grant this capability.
Sourcefn read_text_file_bounded<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
max_bytes: usize,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn read_text_file_bounded<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
max_bytes: usize,
cancel: Option<&'life2 CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Read complete UTF-8 text if it fits in max_bytes. A larger file
yields None. The compatibility default checks the reported size and
then the returned text. Native backends can cap the underlying read.
Sourcefn write_new_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_new_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,
Atomically create an absent file and write its initial contents, never following or replacing an existing final path. The parent must already exist; this capability does not create directories or prove durability.
Unsupported backends fail closed rather than emulating this with an existence check plus truncating write. Cancellation/error after creation may leave a partial new file; never unlink or overwrite it on retry.
Sourcefn open_append_file<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn AppendFile>>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn open_append_file<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn AppendFile>>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Optional reusable append handle for a single-owner journal. Backends without this capability keep the existing per-call append path.
Sourcefn try_acquire_writer_lease<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn WriterLease>>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn try_acquire_writer_lease<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn WriterLease>>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Try to acquire an exclusive writer lease for one addressed journal.
Some is a held capability whose lifetime owns the backend lock;
None means this backend has no process-level lease primitive (for
example the in-memory test backend). Contention is an error, not a
successful None, so callers fail closed when a real backend refuses
ownership.
Sourcefn sync_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_path: &'life1 str,
_data_only: 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 sync_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_path: &'life1 str,
_data_only: 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,
Flush a staged file’s contents through the backend’s durability boundary. The default is a deliberate no-op for memory/Faux backends; callers must not treat it as evidence of physical persistence.
Sourcefn sync_directory<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_path: &'life1 str,
_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 sync_directory<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_path: &'life1 str,
_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,
Flush the directory metadata needed to make a completed rename durable. The default is a deliberate no-op for backends without physical files.
Sourcefn sync_file_and_parent<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
_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 sync_file_and_parent<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
_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,
Sync a regular journal file and its containing directory through an
explicitly supported physical persistence boundary. Unlike sync_file
and sync_directory, the compatibility default fails closed: their
no-op defaults are not evidence that a journal survived a crash.
The caller must own the journal writer and keep the addressed file and parent stable. This does not sync newly-created ancestor directories, progress companions, or protect against writers bypassing ownership.
Sourcefn open_read_file<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Arc<dyn ReadFile>>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn open_read_file<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Arc<dyn ReadFile>>, FileError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Optional stable-generation reader. Unsupported backends retain eager history loading; an actual open failure must be returned, not hidden.
Sourcefn truncate_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
len: u64,
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 truncate_file<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
len: u64,
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,
Cut the file at path back to len bytes, discarding a tail that a
failed append left behind. It never grows a file. Backends without it
fail, so a caller cannot take a tail for clean when it was not cut.
Sourcefn has_file_with_suffix<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
path: &'life1 str,
suffix: &'life2 str,
cancel: Option<&'life3 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,
'life3: 'async_trait,
fn has_file_with_suffix<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
path: &'life1 str,
suffix: &'life2 str,
cancel: Option<&'life3 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,
'life3: 'async_trait,
Whether a directory contains a file or symlink whose name ends with
suffix. Does not follow symlinks and does not cache negative results.
Backends may avoid collecting unrelated entries’ sizes/timestamps.
The default preserves compatibility with existing filesystem adapters.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".