OPFS Rust
Rust wrapper for the the Origin Private File System browser API. When compiling to native platforms, falls back to tokio::fs.
Overview
This crate provides an API for file system operations that automatically uses the appropriate implementation based on the target platform:
- Web (WASM): Uses the Origin Private File System (OPFS) API
- Native platforms: Uses
tokio::fs
An in-memory filesystem is also provided for use in tests (or when persistence isn't necessary)
Features
- Write once, run anywhere: The same code works natively and on the web
- Async/await: All operations are asynchronous
- Type safety: The type-unsafe JsValue soup associated with working with browser APIs from Rust is hidden behind a type-safe API.
Installation
cargo add opfs
Usage
use ;
use ;
use persistent;
// you must import the traits to call methods on the types
use ;
// This code works on both native and web platforms
async
async