pub trait WritableFileSystem: ReadableFileSystem {
Show 13 methods
// Required methods
fn open_with_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
opts: &'life1 OpenOptions,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Self::FileType, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self::FileType: WritableFile,
Self: 'async_trait;
fn copy<'life0, 'async_trait>(
&'life0 self,
from: impl PathType + 'async_trait,
to: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn create_dir<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn create_dir_all<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn hard_link<'life0, 'async_trait>(
&'life0 self,
src: impl PathType + 'async_trait,
dst: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn remove_dir<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn remove_dir_all<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn remove_file<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn rename<'life0, 'async_trait>(
&'life0 self,
from: impl PathType + 'async_trait,
to: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn set_permissions<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
perm: Permissions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn symlink<'life0, 'async_trait>(
&'life0 self,
src: impl PathType + 'async_trait,
dst: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn write<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
contents: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
// Provided method
fn create<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Self::FileType, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self::FileType: WritableFile,
Self: Sync + 'async_trait { ... }
}Expand description
A writable filesystem
Required Methods§
Sourcefn open_with_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
opts: &'life1 OpenOptions,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Self::FileType, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self::FileType: WritableFile,
Self: 'async_trait,
fn open_with_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
opts: &'life1 OpenOptions,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Self::FileType, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self::FileType: WritableFile,
Self: 'async_trait,
Equivalent to
async fn open_with_opts(
&self,
opts: &OpenOptions,
path: impl PathType,
) -> Result<Self::FileType>
where
Self::FileType: WritableFile;Used by OpenOptions::open
Sourcefn copy<'life0, 'async_trait>(
&'life0 self,
from: impl PathType + 'async_trait,
to: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn copy<'life0, 'async_trait>(
&'life0 self,
from: impl PathType + 'async_trait,
to: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Equivalent to
async fn copy(&self, from: impl PathType, to: impl PathType) -> Result<u64>;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 function will overwrite the contents of to.
This is the async equivalent of std::fs::copy
Sourcefn create_dir<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn create_dir<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Equivalent to
async fn create_dir(&self, path: impl PathType) -> Result<()>;Creates a new, empty directory at the provided path.
This is an async version of std::fs::create_dir
§Errors
This function will return an error in the following situations, but is not limited to just these cases:
- User lacks permissions to create directory at
path. - A parent of the given path doesn’t exist. (To create a directory and all
its missing parents at the same time, use the
create_dir_allfunction.) pathalready exists.
Sourcefn create_dir_all<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn create_dir_all<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Equivalent to
async fn create_dir_all(&self, path: impl PathType) -> Result<()>;Recursively creates a directory and all of its parent components if they are missing.
This is an async version of std::fs::create_dir_all
§Errors
This function will return an error in the following situations, but is not limited to just these cases:
- If any directory in the path specified by
pathdoes not already exist and it could not be created otherwise. The specific error conditions for when a directory is being created (after it is determined to not exist) are outlined byfs::create_dir.
Notable exception is made for situations where any of the directories
specified in the path could not be created as it was being created concurrently.
Such cases are considered to be successful. That is, calling create_dir_all
concurrently from multiple threads or processes is guaranteed not to fail
due to a race condition with itself.
Sourcefn hard_link<'life0, 'async_trait>(
&'life0 self,
src: impl PathType + 'async_trait,
dst: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn hard_link<'life0, 'async_trait>(
&'life0 self,
src: impl PathType + 'async_trait,
dst: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Equivalent to
async fn hard_link(&self, src: impl PathType, dst: impl PathType) -> Result<()>;Creates a new hard link on the filesystem.
This is an async version of std::fs::hard_link
The dst path will be a link pointing to the src path.
§Errors
This function will return an error in the following situations, but is not limited to just these cases:
- The
srcpath is not a file or doesn’t exist.
Sourcefn remove_dir<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn remove_dir<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Equivalent to
async fn remove_dir(&self, path: impl PathType) -> Result<()>;Removes an existing, empty directory.
This is an async version of std::fs::remove_dir
Sourcefn remove_dir_all<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn remove_dir_all<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Equivalent to
async fn remove_dir_all(&self, path: impl PathType) -> Result<()>;Removes a directory at this path, after removing all its contents. Use carefully!
This is an async version of std::fs::remove_dir_all
Sourcefn remove_file<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn remove_file<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Equivalent to
async fn remove_file(&self, path: impl PathType) -> Result<()>;Removes a file from the filesystem.
Note that there is no guarantee that the file is immediately deleted (e.g. depending on platform, other open file descriptors may prevent immediate removal).
This is an async version of std::fs::remove_file
Sourcefn rename<'life0, 'async_trait>(
&'life0 self,
from: impl PathType + 'async_trait,
to: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn rename<'life0, 'async_trait>(
&'life0 self,
from: impl PathType + 'async_trait,
to: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Equivalent to
async fn rename(&self, from: impl PathType, to: impl PathType) -> Result<()>;Renames 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<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
perm: Permissions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn set_permissions<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
perm: Permissions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Equivalent to
async fn set_permissions(&self, path: impl PathType, perm: Permissions) -> Result<()>;Changes the permissions found on a file or a directory.
Filesystem implementations may or may not support this.
Sourcefn symlink<'life0, 'async_trait>(
&'life0 self,
src: impl PathType + 'async_trait,
dst: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn symlink<'life0, 'async_trait>(
&'life0 self,
src: impl PathType + 'async_trait,
dst: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Equivalent to
async fn symlink(&self, src: impl PathType, dst: impl PathType) -> Result<()>;Creates a new symbolic link on the filesystem.
The dst path will be a symbolic link pointing to the src path.
This is an async version of std::os::unix::fs::symlink
Sourcefn write<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
contents: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn write<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
contents: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Equivalent to
async fn write(&self, path: impl PathType, contents: impl AsRef<[u8]> + Send) -> Result<()>;Creates a future that will open a file for writing and write the entire
contents of contents to it.
This is the async equivalent of std::fs::write
Provided Methods§
Sourcefn create<'life0, 'async_trait>(
&'life0 self,
path: impl PathType + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Self::FileType, Error>> + Send + 'async_trait>>
fn create<'life0, 'async_trait>( &'life0 self, path: impl PathType + 'async_trait, ) -> Pin<Box<dyn Future<Output = Result<Self::FileType, Error>> + Send + 'async_trait>>
Equivalent to
async fn create(&self, path: impl PathType) -> Result<Self::FileType>
where
Self::FileType: WritableFile;Opens a file in write-only mode.
This function will create a file if it does not exist, and will truncate it if it does.
See OpenOptions for more details.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.