[][src]Module tokio::fs

This is supported on feature="fs" only.

Asynchronous file and standard stream adaptation.

This module contains utility methods and adapter types for input/output to files or standard streams (Stdin, Stdout, Stderr), and filesystem manipulation, for use within (and only within) a Tokio runtime.

Tasks run by worker threads should not block, as this could delay servicing reactor events. Portable filesystem operations are blocking, however. This module offers adapters which use a blocking annotation to inform the runtime that a blocking operation is required. When necessary, this allows the runtime to convert the current thread from a worker to a backup thread, where blocking is acceptable.

Usage

Where possible, users should prefer the provided asynchronous-specific traits such as AsyncRead, or methods returning a Future or Poll type. Adaptions also extend to traits like std::io::Read where methods return std::io::Result. Be warned that these adapted methods may return std::io::ErrorKind::WouldBlock if a worker thread can not be converted to a backup thread immediately.

Modules

osfeature="fs"

OS-specific functionality.

Structs

DirEntryfeature="fs"

Entries returned by the ReadDir stream.

Filefeature="fs"

A reference to an open file on the filesystem.

OpenOptionsfeature="fs"

Options and flags which can be used to configure how a file is opened.

ReadDirfeature="fs"

Stream of the entries in a directory.

Functions

canonicalizefeature="fs"

Returns the canonical, absolute form of a path with all intermediate components normalized and symbolic links resolved.

copyfeature="fs"

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.

create_dirfeature="fs"

Creates a new, empty directory at the provided path

create_dir_allfeature="fs"

Recursively creates a directory and all of its parent components if they are missing.

hard_linkfeature="fs"

Creates a new hard link on the filesystem.

metadatafeature="fs"

Given a path, queries the file system to get information about a file, directory, etc.

readfeature="fs"

Reads the entire contents of a file into a bytes vector.

read_dirfeature="fs"

Returns a stream over the entries within a directory.

read_linkfeature="fs"

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

read_to_stringfeature="fs"

Creates a future which will open a file for reading and read the entire contents into a string and return said string.

remove_dirfeature="fs"

Removes an existing, empty directory.

remove_dir_allfeature="fs"

Removes a directory at this path, after removing all its contents. Use carefully!

remove_filefeature="fs"

Removes a file from the filesystem.

renamefeature="fs"

Renames a file or directory to a new name, replacing the original file if to already exists.

set_permissionsfeature="fs"

Changes the permissions found on a file or a directory.

symlink_metadatafeature="fs"

Queries the file system metadata for a path.

writefeature="fs"

Creates a future that will open a file for writing and write the entire contents of contents to it.