Back to Wasm Bindgen

JSPI + OPFS

guide/src/examples/jspi-opfs.md

0.2.128795 B
Original Source

JSPI + OPFS

View full source code

This example demonstrates JSPI (JS Promise Integration) by calling the browser's fully Promise-based Origin Private File System (OPFS) API from plain (non-async) Rust functions.

Requirements: Chrome 137+ (or 119–136 behind a flag), Firefox 153+, or Safari Technology Preview 238+; a secure context (HTTPS or localhost) for the OPFS API itself.

Cargo.toml

toml
{{#include ../../../examples/jspi-opfs/Cargo.toml}}

src/lib.rs

rust
{{#include ../../../examples/jspi-opfs/src/lib.rs}}