Module fs

Source
Expand description

File system abstraction layer. Currently supporting storage on the filesystem and the browser domain-associated local storage (Web Storage API).

Storage APIs abstracted:

  • Rust std file I/O (fs::xxx)
  • NodeJS file I/O (fs::read_file_sync)
  • Browser local storage

By default, all I/O functions will use the name of the file as a key for localstorage. If you want to manually specify the localstorage key.

Structs§

Buffer
DirEntry
Metadata
Options

Traits§

NormalizePath
Normalizes path, dereferencing relative references . and .. and converting path separators to current platform separators. (detects platform natively or via NodeJS if operating in WASM32 environment)
ToPlatform
Convert path separators to unix or to current platform. Detects platform natively or using NodeJS if operating under WASM32 environment. Since in WASM32 paths default to forward slashes, when running WASM32 in Windows paths needs to be converted back and forth for various path-related functions to work.

Functions§

create_dir_all
create_dir_all_sync
exists
Check if a file exists
exists_sync
Check if a file exists
exists_with_options
exists_with_options_sync
local_storage
normalize
Normalizes path, dereferencing relative references . and .. and converting path separators to current platform separators. (detects platform natively or via NodeJS if operating in WASM32 environment). Uses ToPlatform to perform path conversion.
read
Read binary file contents to a Vec<u8>. If using within the web browser environment, a local storage key with the name of the file will be used and the data is assumed to be hex-encoded.
read_binary_with_options
read_binary_with_options_sync
read_json
Read text file and deserialized it using serde-json.
read_json_sync
Read text file and deserialized it using serde-json.
read_json_with_options
Read text file and deserialized it using serde-json.
read_json_with_options_sync
Read text file and deserialized it using serde-json.
read_sync
Read binary file contents to a Vec<u8>. If using within the web browser environment, a local storage key with the name of the file will be used and the data is assumed to be hex-encoded.
read_to_string
Read file contents to a string. If using within the web browser environment, a local storage key with the name of the file will be used.
read_to_string_sync
Read file contents to a string. If using within the web browser environment, a local storage key with the name of the file will be used.
read_to_string_with_options
read_to_string_with_options_sync
readdir
remove
Remove the file at the given path. If using within the web browser environment, a local storage key with the name of the file will be removed.
remove_sync
Remove the file at the given path. If using within the web browser environment, a local storage key with the name of the file will be removed.
remove_with_options
remove_with_options_sync
rename
rename_sync
resolve_path
Parses the supplied path resolving ~/ to the home directory.
write
Write a Vec<u8> to a binary file. If using within the web browser environment, a local storage key with the name of the file will be used and the data will be hex-encoded.
write_binary_with_options
write_binary_with_options_sync
write_json
Write a serializable value to a text file using serde-json.
write_json_sync
Write a serializable value to a text file using serde-json.
write_json_with_options
Write a serializable value to a text file using serde-json.
write_json_with_options_sync
Write a serializable value to a text file using serde-json.
write_string
Write a string to a text file. If using within the web browser environment, a local storage key with the name of the file will be used.
write_string_sync
Write a string to a text file. If using within the web browser environment, a local storage key with the name of the file will be used.
write_string_with_options
write_string_with_options_sync
write_sync
Write a Vec<u8> to a binary file. If using within the web browser environment, a local storage key with the name of the file will be used and the data will be hex-encoded.