browser-fs
A browser-based filesystem implementation for WebAssembly applications using Rust. This crate provides async filesystem operations similar to std::fs
and async-fs
, designed specifically for browser environments.
Features
- 📂 Full filesystem operations (read, write, create, delete)
- 📁 Directory management (create, list, remove)
- 🔄 Async I/O support
- 📊 File metadata handling
- ⚡ High performance using Web Workers
- 🛡️ Safe Rust implementation
- 🌐 Browser-native using File System Access API
Installation
Add this to your Cargo.toml
:
[]
= "0.1.0"
Usage
Basic File Operations
use File;
use AsyncWriteExt;
// Create and write to a file
async
// Read from a file
use AsyncReadExt;
async
Directory Operations
use ;
use StreamExt;
async
Advanced File Operations
use OpenOptions;
async
Requirements
- WebAssembly environment
- Modern browser with File System Access API support
- Must run in a Web Worker context
Limitations
- Maximum file size of 4GB (due to wasm32 constraints)
- Must run in a Web Worker (not available on main thread)
- Browser security restrictions apply
- Single file handle at a time per file
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Testing
Run the test suite:
License
MIT License
Credits
This project is inspired by the excellent work done in:
Future Plans
- Better concurrent file access
- Better error messages and handling
Safety
This crate uses #![forbid(unsafe_code)]
to ensure 100% safe Rust.
Performance
The crate is designed to be efficient while working within browser constraints. All operations are asynchronous and use modern browser APIs for optimal performance.