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).
Enums§
- Libfw
Error - Errors produced by the WASM engine.
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).