Skip to main content

Module transfer

Module transfer 

Source
Expand description

Upload/download measurements and explicit downloads.

Files are uploaded through tracked message sends, not a preliminary-upload method. Client::download handles a generated downloadFile request. All tracked operations accept the same optional borrowed FnMut(usize, Progress) + Send callback. Its index is the batch position for multiple messages, or zero for single sends and downloads.

§Measurements are not completion

Progress contains coalesced measurements, not a reliable event log or a smoothed percentage. Values may repeat or decrease, and size estimates may change. Zero total means indeterminate; it does not imply an empty file. There are no synthetic initial/final samples. Cached work, rapid completion, or coalescing can mean no callback at all, including for some album items.

Only the operation’s result establishes success. Even current == total does not establish server acceptance of a message.

Callbacks run on the task polling the operation, outside internal locks. They may borrow local state and need not be 'static, but must be Send, short-running, and non-panicking. Offload expensive work yourself. A panic unwinds the operation; it does not cancel native work or shut down its owner.

§Download ranges

Download progress is relative to the requested offset and limit. Only an available contiguous prefix beginning at that offset counts. Cached bytes outside the range and bytes beyond a hole do not increase its progress. A positive limit caps the range; zero means no explicit length limit. Estimates do not replace the final file state returned by TDLib.

§Cancellation versus abandonment

CancellationToken is the Tokio utility token, reexported for convenience. Calling cancel() requests cleanup when the operation is next polled. Dropping the operation only abandons local observation; it does not cancel TDLib work. Do not race cancellation against dropping the same future and expect cleanup to complete.

Download cancellation is file-wide in TDLib. Concurrent download requests for one file can affect one another; they are not independent cancellable slices. Message-send cancellation has different native semantics; see crate::message.

Structs§

CancellationToken
A cooperative cancellation signal for tracked operations.
Progress
A copy-only byte measurement for one tracked transfer.