Skip to content

fs

Filesystem I/O. Sync (`std::fs`) or async (`tokio::fs`) impl picked by the build's runtime feature.

Functions

append

fs::append(path, contents)

Append contents (string or bytes) to path. Creates the file if missing.

append_random

fs::append_random(path, count) -> int

Append count random bytes to path; returns bytes appended. Creates the file if missing.

canonicalize

fs::canonicalize(path) -> string

Resolve symlinks and normalise path against the filesystem.

copy

fs::copy(from, to) -> int

Copy from to to; returns bytes copied.

create_dir

fs::create_dir(path)

Create a single directory. Errors if any parent is missing.

create_dir_all

fs::create_dir_all(path)

Create the directory and any missing parents.

exists

fs::exists(path) -> bool

True if path exists.

is_dir

fs::is_dir(path) -> bool

True if path is an existing directory.

is_file

fs::is_file(path) -> bool

True if path is an existing regular file.

list_dir

fs::list_dir(path) -> list<string>

Names of the entries directly inside the directory at path (non-recursive).

metadata

fs::metadata(path) -> dict

Return #{size, is_file, is_dir, readonly, modified}.

pad_random

fs::pad_random(path, target_size) -> int

Grow path to target_size with random bytes; returns bytes appended.

read

fs::read(path) -> string

Read the file at path as UTF-8 text.

read_bytes

fs::read_bytes(path) -> bytes

Read the file at path as raw bytes.

remove_dir

fs::remove_dir(path)

Delete the directory at path. Errors if not empty.

remove_dir_all

fs::remove_dir_all(path)

Recursively delete the directory at path and all its contents.

remove_file

fs::remove_file(path)

Delete the file at path.

rename

fs::rename(from, to)

Rename / move from to to.

write

fs::write(path, contents)

Write contents (string or bytes) to path, replacing the existing file.

Documentation reflects Ion v0.2.0-66-g3faa376.