pub struct NativeClient { /* private fields */ }Expand description
The native libfw client: one HTTP connection pool + one tuning engine.
All transfer methods take &self, so a single client can be shared across
tasks (Arc<NativeClient>).
Implementations§
Source§impl NativeClient
impl NativeClient
Sourcepub async fn download_file(
&self,
remote: &str,
dest: impl AsRef<Path>,
) -> Result<u64, LibfwError>
pub async fn download_file( &self, remote: &str, dest: impl AsRef<Path>, ) -> Result<u64, LibfwError>
Download remote into dest, resuming a previous partial download
when the server’s ETag still matches.
Returns the number of bytes written by this run (0 when the file
was already complete), so callers can tell a resume from a full fetch.
Emits NativeEvent::FileStart, NativeEvent::Progress (per file),
NativeEvent::FileDone and — with adaptive tuning on —
NativeEvent::Tuning.
Source§impl NativeClient
impl NativeClient
Sourcepub async fn upload_file(
&self,
local: &Path,
remote: &str,
) -> Result<u64, LibfwError>
pub async fn upload_file( &self, local: &Path, remote: &str, ) -> Result<u64, LibfwError>
Upload local to the virtual path remote.
Returns the payload bytes sent by this run (0 when the server already held the whole file). Resumes automatically: a probe reports the ranges the server still has, so an interrupted upload re-sends only the gaps.
Source§impl NativeClient
impl NativeClient
Sourcepub fn new(
base_url: impl Into<String>,
token: impl Into<String>,
client: ClientConfig,
) -> NativeClient
pub fn new( base_url: impl Into<String>, token: impl Into<String>, client: ClientConfig, ) -> NativeClient
Create a client. The HTTP pool is sized by client.concurrency, so
the same knob bounds total network parallelism here and in the browser.
Sourcepub fn with_config(cfg: NativeConfig) -> NativeClient
pub fn with_config(cfg: NativeConfig) -> NativeClient
Create a client from a full NativeConfig.
Sourcepub fn config(&self) -> &ClientConfig
pub fn config(&self) -> &ClientConfig
The configured transfer knobs.
Sourcepub fn tune_status(&self) -> Option<NativeTuneStatus>
pub fn tune_status(&self) -> Option<NativeTuneStatus>
A snapshot of the adaptive tuning engine (phase, live params, stats).
Sourcepub fn capabilities(&self) -> Option<Capabilities>
pub fn capabilities(&self) -> Option<Capabilities>
The capabilities currently loaded from the server, if any.
Sourcepub async fn list(&self, dir: &str) -> Result<Vec<RemoteFile>, LibfwError>
pub async fn list(&self, dir: &str) -> Result<Vec<RemoteFile>, LibfwError>
List the immediate children of a virtual directory (empty = root).
Sourcepub async fn stat(&self, remote: &str) -> Result<RemoteStat, LibfwError>
pub async fn stat(&self, remote: &str) -> Result<RemoteStat, LibfwError>
Fetch a remote file’s authoritative size and ETag (HEAD).
A directory answers 404 (there is no file to stat), which makes this
a cheap way to tell “file” from “folder” before downloading.
Sourcepub async fn download_folder(
&self,
dir: &str,
dest_dir: impl AsRef<Path>,
) -> Result<u64, LibfwError>
pub async fn download_folder( &self, dir: &str, dest_dir: impl AsRef<Path>, ) -> Result<u64, LibfwError>
Download every file under dir into dest_dir, preserving structure.
Files are fetched with up to concurrency concurrent transfers; each
one uses the per-file download_window (parallel Range GETs) when
the tuning engine says the link needs it.
Sourcepub async fn upload_files(
&self,
files: Vec<(PathBuf, String)>,
) -> Result<u64, LibfwError>
pub async fn upload_files( &self, files: Vec<(PathBuf, String)>, ) -> Result<u64, LibfwError>
Upload files (local path → virtual remote path pairs).
Runs concurrency files in parallel; each file uses the session
protocol, so an interrupted upload resumes from the server’s own
received-range report instead of re-sending everything.
Sourcepub async fn upload_folder(
&self,
local_dir: impl AsRef<Path>,
remote_dir: &str,
) -> Result<u64, LibfwError>
pub async fn upload_folder( &self, local_dir: impl AsRef<Path>, remote_dir: &str, ) -> Result<u64, LibfwError>
Upload a whole local directory tree, mirroring its structure under
remote_dir (POSIX separators).
Sourcepub async fn fetch_capabilities(&self) -> Result<Capabilities, LibfwError>
pub async fn fetch_capabilities(&self) -> Result<Capabilities, LibfwError>
GET /capabilities — the server’s advertised limits and codecs.
This is a network call (the endpoint is public, no credentials
needed); NativeClient::capabilities returns the cached copy the
tuning engine loaded during the last transfer.