pub trait FileSystem: Send + Sync {
Show 17 methods
// Required methods
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn write<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 Path,
bytes: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn create_dir_all<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn read_dir<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<DirEntry>, ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn remove_dir_all<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Metadata, ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn canonicalize<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn rename<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
_to: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn remove_file<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn write_not_following<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 Path,
bytes: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn write_resolved<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 Path,
bytes: &'life2 [u8],
create_parents: bool,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn sha256<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn read_to_string<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<String, ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn write_str<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 Path,
text: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn metadata_following_symlinks<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Metadata, ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn read_link<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, ExecError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn canonicalize_best_effort<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = PathBuf> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Where a tool’s files are.
Whole-value rather than streaming, which is the opposite of Process and
deliberately so: every call site in the engine reads or writes a whole
file, and a tool result is capped long before a file could be large enough
to need chunking. Designing a streaming interface with no consumer would
oblige every implementation to provide one.
Path safety is not here. Whether a path may be written is a policy —
it answers the same question regardless of which machine the file is on,
and a provider that decided its own out-of-bounds rules could cancel them.
It stays in permissions::path_safety, above this contract.
One thing does cross: canonicalize. A remote’s
symlink graph is the remote’s, so resolving one here would answer about the
wrong filesystem. The order is: canonicalize through the provider, check
the resolved path against the policy, then write through the provider.
Required Methods§
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn write<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 Path,
bytes: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn create_dir_all<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read_dir<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<DirEntry>, ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove_dir_all<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Metadata, ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn canonicalize<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Provided Methods§
Sourcefn rename<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
_to: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn rename<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
_to: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Move from to to on this filesystem. Provided, for a provider
that cannot: it fails and moves nothing.
Sourcefn remove_file<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove_file<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove the file at path — a symlink itself, never what it points
at. Provided, for a provider that cannot: it fails and removes nothing.
Sourcefn write_not_following<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 Path,
bytes: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn write_not_following<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 Path,
bytes: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
write, refusing when path itself is a symlink
rather than writing where it points. Provided as a check then a write;
a provider that can do both in one step (O_NOFOLLOW) should.
Sourcefn write_resolved<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 Path,
bytes: &'life2 [u8],
create_parents: bool,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn write_resolved<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 Path,
bytes: &'life2 [u8],
create_parents: bool,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Write bytes to path — absolute, its symlinks already resolved —
following no symlink on the way: a component that is one by the time
it is reached fails the write instead of taking it elsewhere. With
create_parents, missing directories on the way are made.
Provided as checks then a write; a provider that can walk the path from directory to directory without following links should.
Sourcefn sha256<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sha256<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
The file’s sha256 as lowercase hex, hashed without holding the file.
None for a provider that cannot, which the caller answers by
reading — and so only for files it can afford to read.
Sourcefn read_to_string<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<String, ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read_to_string<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<String, ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
What most callers actually want. Provided, so an implementor writes
read and gets this.
Sourcefn write_str<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 Path,
text: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn write_str<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 Path,
text: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Convenience with the same relationship to write.
Sourcefn metadata_following_symlinks<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Metadata, ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn metadata_following_symlinks<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Metadata, ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Metadata of what path points at rather than of path itself.
metadata reports on the link — that is what its
is_symlink field is for — so a caller asking “how big is this, is it
a directory” has to resolve first or a symlink to a directory answers
as a small ordinary file.
Sourcefn read_link<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read_link<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<PathBuf, ExecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
What the symbolic link at path points at, as written in the link.
Provided, for a provider with no links: it fails.
Sourcefn canonicalize_best_effort<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = PathBuf> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn canonicalize_best_effort<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = PathBuf> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
The resolved form of a path that may not exist yet: its deepest prefix
that exists, resolved by canonicalize, with
the rest put back on.
A write policy has to be checked against where the write lands. The
rest does not exist, so it has no symlinks — except a link whose
target does not exist yet, which canonicalize cannot resolve and a
write follows; that one is followed here with
read_link.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".