Expand description
libfw-client: WASM engine for browser file & folder transfers.
This crate ships the engine that runs inside the browser: it performs
the HTTP transfer (via fetch), slices files into chunks, keeps memory
constant, retries with exponential backoff, and drives the task state
machine (idle → downloading/uploading → paused → resumed → completed/failed).
The LibfwClient WASM class is exported through wasm-bindgen and is
intended to be wrapped by the accompanying JS SDK (sdk/). The SDK owns
WASM instantiation, the File System Access API, IndexedDB persistence and
the createWritable byte sink — all data crosses the boundary through
the callbacks installed via LibfwClient::set_callbacks.
§Callbacks object
engine.set_callbacks({
onFileStart(path, size) {},
onWriteChunk(path, offset, data) {}, // Uint8Array
onFileCompleted(path) {},
onProgress(done, total) {},
loadState(direction, path) { return Promise.resolve(null); }, // IndexedDB
saveState(direction, path, state) { return Promise.resolve(); },// IndexedDB
getFileList() { return Promise.resolve([]); }, // uploads
readFile(path, offset, length) { return Promise.resolve(new Uint8Array(0)); },
log(msg) {},
});Structs§
- Client
Config - Runtime configuration of the WASM engine.
- File
Entry - A file to transfer, identified by its virtual path.
- Libfw
Client - WASM engine facade. Construct via
new LibfwClient(options). - Local
Store - localStorage-backed store (only reachable in the browser).
- Tune
Cache - Persisted tuning cache entry (
localStorage["libfw.tune.<originHash>"]). - Tune
Event - A tuning event emitted when a window evaluation changed the state.
- Tune
Params - The shared, live parameter table.
- Tune
Stats - Smoothed transfer statistics.
Enums§
- Compress
Level - Client-side compression level configuration.
- Libfw
Error - Errors produced by the WASM engine.
- Transfer
Kind - Which transfer direction is ramping (drives which window/chunk dims move).
- Tune
Phase - Lifecycle of the tuning state machine.
Traits§
- Tune
Store - Injected persistence backend (localStorage in the browser; a map in tests).
Functions§
- backoff_
ms - Pure exponential backoff:
min(max, base << attempt)with saturation. - js_
option_ string - Read an optional string field from a JS object (helper for the SDK).
- start
- tune_
key - The localStorage key for a base URL:
libfw.tune.<originHash>.
Type Aliases§
- Tune
Handle - Shared handle to the tuning engine (Rc so clones share one table).