pub trait FileSystem: Sync + Send {
Show 27 methods // Required methods fn open_file( &self, waker: Waker, path: &Path, open_mode: &FileOpenMode ) -> CancelablePoll<Result<Handle>>; fn file_write( &self, waker: Waker, file: &Handle, buf: &[u8] ) -> CancelablePoll<Result<usize>>; fn file_read( &self, waker: Waker, file: &Handle, buf: &mut [u8] ) -> CancelablePoll<Result<usize>>; fn file_flush( &self, waker: Waker, file: &Handle ) -> CancelablePoll<Result<()>>; fn file_seek( &self, waker: Waker, file: &Handle, pos: SeekFrom ) -> CancelablePoll<Result<u64>>; fn file_meta( &self, waker: Waker, file: &Handle ) -> CancelablePoll<Result<Metadata>>; fn file_set_permissions( &self, waker: Waker, file: &Handle, perm: &Permissions ) -> CancelablePoll<Result<()>>; fn file_set_len( &self, waker: Waker, file: &Handle, size: u64 ) -> CancelablePoll<Result<()>>; fn canonicalize( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<PathBuf>>; fn copy( &self, waker: Waker, from: &Path, to: &Path ) -> CancelablePoll<Result<u64>>; fn create_dir( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<()>>; fn create_dir_all( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<()>>; fn hard_link( &self, waker: Waker, from: &Path, to: &Path ) -> CancelablePoll<Result<()>>; fn metadata( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<Metadata>>; fn read_dir( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<Handle>>; fn dir_entry_next( &self, waker: Waker, read_dir_handle: &Handle ) -> CancelablePoll<Result<Option<Handle>>>; fn dir_entry_file_name(&self, entry: &Handle) -> String; fn dir_entry_path(&self, entry: &Handle) -> PathBuf; fn dir_entry_metadata( &self, waker: Waker, entry: &Handle ) -> CancelablePoll<Result<Metadata>>; fn dir_entry_file_type( &self, waker: Waker, entry: &Handle ) -> CancelablePoll<Result<FileType>>; fn read_link( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<PathBuf>>; fn remove_dir( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<()>>; fn remove_dir_all( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<()>>; fn remove_file( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<()>>; fn rename( &self, waker: Waker, from: &Path, to: &Path ) -> CancelablePoll<Result<()>>; fn set_permissions( &self, waker: Waker, path: &Path, perm: &Permissions ) -> CancelablePoll<Result<()>>; fn symlink_metadata( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<Metadata>>;
}
Available on crate feature fs only.
Expand description

Filesystem-related system call interface

Required Methods§

source

fn open_file( &self, waker: Waker, path: &Path, open_mode: &FileOpenMode ) -> CancelablePoll<Result<Handle>>

Opens a file with FileOpenMode

source

fn file_write( &self, waker: Waker, file: &Handle, buf: &[u8] ) -> CancelablePoll<Result<usize>>

Write a buffer into this writer, returning how many bytes were written

source

fn file_read( &self, waker: Waker, file: &Handle, buf: &mut [u8] ) -> CancelablePoll<Result<usize>>

Pull some bytes from this source into the specified buffer, returning how many bytes were read.

source

fn file_flush(&self, waker: Waker, file: &Handle) -> CancelablePoll<Result<()>>

Attempts to sync all OS-internal metadata to disk.

This function will attempt to ensure that all in-memory data reaches the filesystem before returning.

This can be used to handle errors that would otherwise only be caught when the File is closed. Dropping a file will ignore errors in synchronizing this in-memory data.

source

fn file_seek( &self, waker: Waker, file: &Handle, pos: SeekFrom ) -> CancelablePoll<Result<u64>>

Seek to an offset, in bytes, in a stream.

A seek beyond the end of a stream is allowed, but behavior is defined by the implementation.

If the seek operation completed successfully, this method returns the new position from the start of the stream. That position can be used later with SeekFrom::Start.

§Errors

Seeking can fail, for example because it might involve flushing a buffer.

Seeking to a negative offset is considered an error.

source

fn file_meta( &self, waker: Waker, file: &Handle ) -> CancelablePoll<Result<Metadata>>

Reads the file’s metadata.

source

fn file_set_permissions( &self, waker: Waker, file: &Handle, perm: &Permissions ) -> CancelablePoll<Result<()>>

Changes the permissions on the file.

source

fn file_set_len( &self, waker: Waker, file: &Handle, size: u64 ) -> CancelablePoll<Result<()>>

Truncates or extends the file.

If size is less than the current file size, then the file will be truncated. If it is greater than the current file size, then the file will be extended to size and have all intermediate data filled with zeros.

The file’s cursor stays at the same position, even if the cursor ends up being past the end of the file after this operation.

source

fn canonicalize( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<PathBuf>>

Returns the canonical form of a path. The returned path is in absolute form with all intermediate components normalized and symbolic links resolved. This function is an async version of std::fs::canonicalize.

source

fn copy( &self, waker: Waker, from: &Path, to: &Path ) -> CancelablePoll<Result<u64>>

Copies the contents and permissions of a file to a new location. On success, the total number of bytes copied is returned and equals the length of the to file after this operation. The old contents of to will be overwritten. If from and to both point to the same file, then the file will likely get truncated as a result of this operation.

source

fn create_dir(&self, waker: Waker, path: &Path) -> CancelablePoll<Result<()>>

Creates a new directory. Note that this function will only create the final directory in path. If you want to create all of its missing parent directories too, use the create_dir_all function instead.

This function is an async version of std::fs::create_dir.

source

fn create_dir_all( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<()>>

Creates a new directory and all of its parents if they are missing. This function is an async version of std::fs::create_dir_all.

Creates a hard link on the filesystem. The dst path will be a link pointing to the src path. Note that operating systems often require these two paths to be located on the same filesystem.

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

source

fn metadata( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<Metadata>>

Reads metadata for a path. This function will traverse symbolic links to read metadata for the target file or directory. If you want to read metadata without following symbolic links, use symlink_metadata instead.

This function is an async version of std::fs::metadata.

source

fn read_dir(&self, waker: Waker, path: &Path) -> CancelablePoll<Result<Handle>>

Returns a iterator handle of entries in a directory.

See dir_entry_next for more information about iteration.

source

fn dir_entry_next( &self, waker: Waker, read_dir_handle: &Handle ) -> CancelablePoll<Result<Option<Handle>>>

Advances the directory entry iterator and returns the next value.

Returns None when iteration is finished.

You can create a directory entry iterator by call function read_dir

source

fn dir_entry_file_name(&self, entry: &Handle) -> String

Returns the bare name of this entry without the leading path.

source

fn dir_entry_path(&self, entry: &Handle) -> PathBuf

Returns the full path to this entry. The full path is created by joining the original path passed to read_dir with the name of this entry.

source

fn dir_entry_metadata( &self, waker: Waker, entry: &Handle ) -> CancelablePoll<Result<Metadata>>

Reads the metadata for this entry.

This function will traverse symbolic links to read the metadata.

source

fn dir_entry_file_type( &self, waker: Waker, entry: &Handle ) -> CancelablePoll<Result<FileType>>

eads the file type for this entry. This function will not traverse symbolic links if this entry points at one. If you want to read metadata with following symbolic links, use dir_entry_metadata instead.

Reads a symbolic link and returns the path it points to.

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

source

fn remove_dir(&self, waker: Waker, path: &Path) -> CancelablePoll<Result<()>>

Removes an empty directory, if the path is not an empty directory, use the function remove_dir_all instead.

This function is an async version of std::fs::remove_dir.

source

fn remove_dir_all( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<()>>

Removes a directory and all of its contents.

This function is an async version of std::fs::remove_dir_all.

source

fn remove_file(&self, waker: Waker, path: &Path) -> CancelablePoll<Result<()>>

Removes a file. This function is an async version of std::fs::remove_file.

source

fn rename( &self, waker: Waker, from: &Path, to: &Path ) -> CancelablePoll<Result<()>>

Renames a file or directory to a new location. If a file or directory already exists at the target location, it will be overwritten by this operation. This function is an async version of std::fs::rename.

source

fn set_permissions( &self, waker: Waker, path: &Path, perm: &Permissions ) -> CancelablePoll<Result<()>>

Changes the permissions of a file or directory. This function is an async version of std::fs::set_permissions.

Reads metadata for a path without following symbolic links. If you want to follow symbolic links before reading metadata of the target file or directory, use metadata instead.

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

Implementors§