Skip to main content

Module native

Module native 

Source
Expand description

Native (non-WASM) Rust client: async reqwest transport speaking the same wire protocol as the browser engine. Native (non-WASM) client: an async Rust transport for the libfw protocol.

This is the “Rust crate” half of libfw-client. It speaks the exact same wire protocol as the browser engine (wasm module) — resumable Range downloads, the tus-style session upload protocol, zrip compression and /capabilities driven adaptive tuning — but over tokio + reqwest instead of fetch/XHR, so a plain Rust binary, service or script can move files to a libfw server.

§What it shares with the browser engine

  • ClientConfig — the same knobs (concurrency, windows, chunk size, retries, timeouts, auto_tune, compression policy).
  • The same adaptive tuning engine, so “good vs. bad network” behaviour is identical to the SDK: it ramps the per-file window, cross-file concurrency and chunk size against the server’s advertised limits and settles where the link saturates. The settle is remembered in memory and reused by the next transfer of this client.
  • libfw-core — headers, metadata, compression and range math.

§What differs from the browser engine

  • Resume state lives in a small JSON sidecar next to the destination file instead of IndexedDB.
  • Tuning state is in memory only, for the lifetime of the client: a settle is reused by later transfers of the same client, and a new client always re-measures the link from the advertised minimums. The browser engine additionally caches its settle in localStorage (bounded by tune_ttl_ms); the native client installs no store, so tune_ttl_ms has no effect here.
  • No File System Access API: downloads are written with ordinary file IO.
  • Cancellation is structural: drop the transfer future (or wrap it in tokio::select! / tokio::time::timeout). Both directions are resumable, so an abandoned transfer costs at most the in-flight blocks.

§Example

use libfw_client::{ClientConfig, native::NativeClient};

let mut config = ClientConfig::default();
config.auto_tune = true; // adapt to the link via /capabilities

let client = NativeClient::new("http://127.0.0.1:8080", "dev-token", config);
let bytes = client.download_file("docs/plan.pdf", "plan.pdf").await?;
println!("downloaded {bytes} bytes");

Structs§

NativeClient
The native libfw client: one HTTP connection pool + one tuning engine.
NativeConfig
Configuration for NativeClient.
NativeTuneStatus
Snapshot of the adaptive tuning engine, for logging/metrics.
RemoteFile
A directory listing entry as served by GET /dir/....
RemoteStat
Metadata of a remote file, as returned by NativeClient::stat.

Enums§

NativeEvent
A progress/lifecycle notification (mirrors the SDK’s onEvent stream).

Type Aliases§

EventSink
Shared, thread-safe progress sink.