Module workflow_store::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 sile I/O (fs::xxx)
- NodeJS sile 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
Traits
- Normalizes path, dereferencing relative references
.
and..
and converting path separators to current platform separators. (detects platform nativly or via NodeJS if operating in WASM32 environment) - 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
- Check if a file exists
- Normalizes path, dereferencing relative references
.
and..
and converting path separators to current platform separators. (detects platform nativly or via NodeJS if operating in WASM32 environment). UsesToPlatform
to perform path conversion. - Read binary file contents to a
Vec<u8>
. If using wtihin 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 text file and deserialized it using
serde-json
. - Read text file and deserialized it using
serde-json
. - Read file contents to a string. If using wtihin the web browser environment, a local storage key with the name of the file will be used.
- Remove the file at the given path. If using wtihin the web browser environment, a local storage key with the name of the file will be removed.
- Parses the supplied path resolving
~/
to the home directory. - Write a
Vec<u8>
to a binary file. If using wtihin 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 a serializable value to a text file using
serde-json
. - Write a serializable value to a text file using
serde-json
. - Write a string to a text file. If using wtihin the web browser environment, a local storage key with the name of the file will be used.