Skip to main content

FSRuntime

Trait FSRuntime 

Source
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§

Source

type File: RuntimeFile<Runtime = Self>

Runtime’s file.

Source

type DirEntry: RuntimeDirEntry

Runtime’s dir entry.

Required Methods§

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Reads a symbolic link, returning the file that the link points to.

This is an async version of std::fs::read_link

Available on Unix only.

Creates a new symbolic link on the filesystem.

This is an async version of std::os::unix::fs::symlink

Available on Windows only.

Creates a new symlink to a directory on the filesystem.

This is async version of [std::os::windows::fs::symlink_dir].

Available on Windows only.

Creates a new symlink to a non-directory file on the filesystem.

This is async version of [std::os::windows::fs::symlink_file].

Creates a new hard link on the filesystem.

This is an async version of std::fs::hard_link

Source

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

Source

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

Source

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

Source

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

Query the metadata about a file without following symlinks.

This is an async version of std::fs::symlink_metadata

Provided Methods§

Source

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

Source

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

Source

fn write( &self, path: impl AsRef<Path> + Send, content: &[u8], ) -> impl Future<Output = Result<()>> + Send

Write a slice as the entire contents of a file.

This is an async version of std::fs::write

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§