#opfs #browser #storage

opfs-project

A Rust library for working with the Origin Private File System (OPFS) in WebAssembly applications

22 releases

Uses new Rust 2024

0.2.3 Jan 14, 2026
0.2.2 Jan 12, 2026
0.1.17 Jan 16, 2026
0.1.16 Dec 30, 2025
0.1.4 Aug 29, 2025

#439 in Filesystem

Download history 261/week @ 2025-10-22 160/week @ 2025-10-29 111/week @ 2025-11-05 59/week @ 2025-11-12 173/week @ 2025-11-19 326/week @ 2025-11-26 168/week @ 2025-12-03 341/week @ 2025-12-10 1348/week @ 2025-12-17 1192/week @ 2025-12-24 410/week @ 2025-12-31 784/week @ 2026-01-07 515/week @ 2026-01-14 786/week @ 2026-01-21 503/week @ 2026-01-28 492/week @ 2026-02-04

2,351 downloads per month

MIT license

64KB
1.5K SLoC

OPFS Project

A Rust library for working with the Origin Private File System (OPFS) in WebAssembly applications.

Features

  • File and directory operations in OPFS
  • Support for fuse.link files to create symbolic links between directories
  • Package management functionality for handling npm-style dependencies
  • Asynchronous API for all file operations

Use Cases

  • Web applications that need persistent local storage
  • Package managers for web-based development environments
  • Applications that need to manage complex file structures in the browser
  • Tools that require fast access to local files without user interaction

Development Setup

  1. Install Rust and Cargo
  2. Install wasm-pack: cargo install wasm-pack
  3. Build the project: wasm-pack build
  4. Run tests: wasm-pack test --chrome --headless

API

File Operations

  • opfs::read_dir(path) - Read directory contents
  • opfs::read(path) - Read file contents
  • opfs::write(path, content) - Write content to file
  • opfs::create_dir_all(path) - Create directory and all parent directories
  • opfs::remove(path) - Remove a file
  • opfs::exists(path) - Check if file or directory exists

Package Management

  • package_manager::install_deps(package_lock, max_concurrent_downloads) - Install dependencies from package-lock.json with specified concurrency limit
  • fuse::fuse_link(src, dst) - Create fuse link between source and destination directories
  • fuse::read(path) - Read file content with fuse.link support
  • fuse::read_dir(path) - Read directory contents with fuse.link support

Testing

Tests are written using wasm-bindgen-test and can be run with:

wasm-pack test --chrome --headless

Note: Tests require a modern browser with OPFS support (Firefox 116+, Chrome 114+).

License

MIT

Dependencies

~17–36MB
~457K SLoC