Skip to main content

NativeClient

Struct NativeClient 

Source
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

Source

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

Source

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

Source

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.

Source

pub fn with_config(cfg: NativeConfig) -> NativeClient

Create a client from a full NativeConfig.

Source

pub fn config(&self) -> &ClientConfig

The configured transfer knobs.

Source

pub fn tune_status(&self) -> Option<NativeTuneStatus>

A snapshot of the adaptive tuning engine (phase, live params, stats).

Source

pub fn capabilities(&self) -> Option<Capabilities>

The capabilities currently loaded from the server, if any.

Source

pub async fn list(&self, dir: &str) -> Result<Vec<RemoteFile>, LibfwError>

List the immediate children of a virtual directory (empty = root).

Source

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.

Source

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.

Source

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.

Source

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

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more