pub trait FSRuntime: Send + Sync {
type File: RuntimeFile<Runtime = Self>;
type DirEntry: RuntimeDirEntry;
Show 20 methods
// Required methods
fn canonicalize(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<PathBuf>> + Send;
fn copy(
&self,
from: impl AsRef<Path> + Send,
to: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<u64>> + Send;
fn create_dir(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send;
fn create_dir_all(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send;
fn remove_dir(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send;
fn remove_dir_all(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send;
fn read_dir(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<impl Stream<Item = Result<Self::DirEntry>> + Send>> + Send;
fn read_link(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<PathBuf>> + Send;
fn symlink(
&self,
from: impl AsRef<Path> + Send,
to: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send;
fn symlink_dir(
&self,
from: impl AsRef<Path> + Send,
to: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send;
fn symlink_file(
&self,
from: impl AsRef<Path>,
to: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send;
fn hard_link(
&self,
from: impl AsRef<Path> + Send,
to: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send;
fn metadata(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<Metadata>> + Send;
fn remove_file(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send;
fn rename(
&self,
from: impl AsRef<Path> + Send,
to: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send;
fn set_permissions(
&self,
path: impl AsRef<Path> + Send,
permissions: Permissions,
) -> impl Future<Output = Result<()>> + Send;
fn symlink_metadata(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<Metadata>> + Send;
// Provided methods
fn read(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<Vec<u8>>> + Send { ... }
fn read_to_string(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<String>> + Send { ... }
fn write(
&self,
path: impl AsRef<Path> + Send,
content: &[u8],
) -> impl Future<Output = Result<()>> + Send { ... }
}Expand description
Represents an async runtime that supports asynchronous access to filesystem.
Required Associated Types§
Sourcetype File: RuntimeFile<Runtime = Self>
type File: RuntimeFile<Runtime = Self>
Runtime’s file.
Sourcetype DirEntry: RuntimeDirEntry
type DirEntry: RuntimeDirEntry
Runtime’s dir entry.
Required Methods§
Sourcefn canonicalize(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<PathBuf>> + Send
fn canonicalize( &self, path: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<PathBuf>> + Send
Returns the canonical, absolute form of a path with all intermediate components normalized and symbolic links resolved.
This is an async version of std::fs::canonicalize
Sourcefn copy(
&self,
from: impl AsRef<Path> + Send,
to: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<u64>> + Send
fn copy( &self, from: impl AsRef<Path> + Send, to: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<u64>> + Send
Copies the contents of one file to another. This function will also copy the permission bits of the original file to the destination file.
This is an async version of std::fs::copy
Sourcefn create_dir(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send
fn create_dir( &self, path: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<()>> + Send
Creates a new, empty directory at the provided path.
This is an async version of std::fs::create_dir
Sourcefn create_dir_all(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send
fn create_dir_all( &self, path: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<()>> + Send
Recursively create a directory and all of its parent components if they are missing.
This is an async version of std::fs::create_dir_all
Sourcefn remove_dir(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send
fn remove_dir( &self, path: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<()>> + Send
Removes an empty directory.
This is an async version of std::fs::remove_dir
Sourcefn remove_dir_all(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send
fn remove_dir_all( &self, path: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<()>> + Send
Returns an iterator over the entries within a directory.
This is an async version of std::fs::remove_dir_all
Sourcefn read_dir(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<impl Stream<Item = Result<Self::DirEntry>> + Send>> + Send
fn read_dir( &self, path: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<impl Stream<Item = Result<Self::DirEntry>> + Send>> + Send
Returns a stream over the entries within a directory.
This is an async version of std::fs::read_dir
Sourcefn read_link(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<PathBuf>> + Send
fn read_link( &self, path: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<PathBuf>> + Send
Reads a symbolic link, returning the file that the link points to.
This is an async version of std::fs::read_link
Sourcefn symlink(
&self,
from: impl AsRef<Path> + Send,
to: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send
Available on Unix only.
fn symlink( &self, from: impl AsRef<Path> + Send, to: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<()>> + Send
Creates a new symbolic link on the filesystem.
This is an async version of std::os::unix::fs::symlink
Sourcefn symlink_dir(
&self,
from: impl AsRef<Path> + Send,
to: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send
Available on Windows only.
fn symlink_dir( &self, from: impl AsRef<Path> + Send, to: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<()>> + Send
Creates a new symlink to a directory on the filesystem.
This is async version of [std::os::windows::fs::symlink_dir].
Sourcefn symlink_file(
&self,
from: impl AsRef<Path>,
to: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send
Available on Windows only.
fn symlink_file( &self, from: impl AsRef<Path>, to: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<()>> + Send
Creates a new symlink to a non-directory file on the filesystem.
This is async version of [std::os::windows::fs::symlink_file].
Sourcefn hard_link(
&self,
from: impl AsRef<Path> + Send,
to: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send
fn hard_link( &self, from: impl AsRef<Path> + Send, to: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<()>> + Send
Creates a new hard link on the filesystem.
This is an async version of std::fs::hard_link
Sourcefn metadata(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<Metadata>> + Send
fn metadata( &self, path: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<Metadata>> + Send
Given a path, query the file system to get information about a file, directory, etc.
This is an async version of std::fs::metadata
Sourcefn remove_file(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send
fn remove_file( &self, path: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<()>> + Send
Removes a file from the filesystem.
This is an async version of std::fs::remove_file
Sourcefn rename(
&self,
from: impl AsRef<Path> + Send,
to: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<()>> + Send
fn rename( &self, from: impl AsRef<Path> + Send, to: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<()>> + Send
Rename a file or directory to a new name, replacing the original file if
to already exists.
This is an async version of std::fs::rename
Sourcefn set_permissions(
&self,
path: impl AsRef<Path> + Send,
permissions: Permissions,
) -> impl Future<Output = Result<()>> + Send
fn set_permissions( &self, path: impl AsRef<Path> + Send, permissions: Permissions, ) -> impl Future<Output = Result<()>> + Send
Changes the permissions found on a file or a directory.
This is an async version of std::fs::set_permissions
Sourcefn symlink_metadata(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<Metadata>> + Send
fn symlink_metadata( &self, path: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<Metadata>> + Send
Query the metadata about a file without following symlinks.
This is an async version of std::fs::symlink_metadata
Provided Methods§
Sourcefn read(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<Vec<u8>>> + Send
fn read( &self, path: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<Vec<u8>>> + Send
Read the entire contents of a file into a bytes vector.
This is an async version of std::fs::read
Sourcefn read_to_string(
&self,
path: impl AsRef<Path> + Send,
) -> impl Future<Output = Result<String>> + Send
fn read_to_string( &self, path: impl AsRef<Path> + Send, ) -> impl Future<Output = Result<String>> + Send
Read the entire contents of a file into a string.
This is an async version of std::fs::read_to_string
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".