Skip to main content

Crate libfw_client

Crate libfw_client 

Source
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§

ClientConfig
Runtime configuration of the WASM engine.
FileEntry
A file to transfer, identified by its virtual path.
LibfwClient
WASM engine facade. Construct via new LibfwClient(options).

Enums§

LibfwError
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).