Expand description
Browser filesystem primitives.
This crate is an async version of std::fs
that is designed to work in a
browser, only in a web worker.
It is supposed to provide an API similar to async-fs
.
This crate is inspired by web-fs
which provides a mechanism of using the browser filesystem
from the main thread, which is not the case for the current implementation,
making it simpler and easier to integrate if your app already works in a web
worker.
§Known constraints
§File size
wasm32
only support at most 4GB memory, therefore it’s not possible to
handle files bigger than that.
§Concurrent access
The current implementation, based on web-sys
cannot open multiple file
handler at the same time on the same file. The underneath implementation is
blocking this by returning an error.
§Examples
Create a new file and write some bytes to it:
use browser_fs::File;
use futures_lite::io::AsyncWriteExt;
let mut file = File::create("a.txt").await?;
file.write_all(b"Hello, world!").await?;
file.flush().await?;
Structs§
- DirEntry
- An entry in a directory.
- File
- An open file on the filesystem.
- Metadata
- Metadata information about a file.
- Open
Options - A builder for opening files with configurable options.
- Permissions
- Representation of the various permissions on a file.
Enums§
Functions§
- create_
dir - Creates a new, empty directory at the provided path
- create_
dir_ all - Recursively create a directory and all of its parent components if they are missing.
- metadata
- Reads metadata for a path.
- read
- Reads the entire contents of a file as raw bytes.
- read_
dir - Returns a stream of entries in a directory.
- read_
to_ string - Reads the entire contents of a file as a string.
- remove_
dir - Removes an empty directory.
- remove_
dir_ all - Removes a directory and all of its contents.
- remove_
file - Removes a file.
- write
- Writes a slice of bytes as the new contents of a file.