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).
LocalStore
localStorage-backed store (only reachable in the browser).
TuneCache
Persisted tuning cache entry (localStorage["libfw.tune.<originHash>"]).
TuneEvent
A tuning event emitted when a window evaluation changed the state.
TuneParams
The shared, live parameter table.
TuneStats
Smoothed transfer statistics.

Enums§

CompressLevel
Client-side compression level configuration.
LibfwError
Errors produced by the WASM engine.
TransferKind
Which transfer direction is ramping (drives which window/chunk dims move).
TunePhase
Lifecycle of the tuning state machine.

Traits§

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

TuneHandle
Shared handle to the tuning engine (Rc so clones share one table).