1 unstable release
0.1.0 | May 29, 2019 |
---|
#5 in #web-based
7KB
69 lines
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.
Dependencies
~3.5MB
~76K SLoC