Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 948 Bytes

README.md

File metadata and controls

23 lines (18 loc) · 948 Bytes

localstoragefs

Web-based replacement for std::fs using localStorage

Intended as a drop-in replacement when building for wasm32-unknown-unknown for HTML5. Example of supporting both native and web with the same API using cfg-if:

cfg_if! {
    if #[cfg(target_arch = "wasm32")] {
        use localstoragefs::fs;
    } else {
        use std::fs;
    }
}

then use fs::File as usual. Not all functionality is supported (contributions welcome), but at least minimal usage should work. See examples/hello for a complete example.

Inspired by Emscripten's file system support (Rust target wasm32-unknown-emscripten), but not as complete. Files are stored as local storage string values with hex-encoded data. May not be as efficient as alternatives.