Skip to main content

Module events

Module events 

Source
Expand description

The typed transfer event stream: what an upload, a push or a fetch is doing, as it does it, for a caller that renders progress (the TUI’s transfer view, a mobile progress bar).

Progress used to exist only as tracing lines, which a UI cannot consume. A TransferEvents handle is attached to the clients that move bytes — UploadClient::with_events (which push_bundle drives), verify_custody_with_events and RangedFetcher::with_events — and every subscriber receives each TransferEvent in the order the client took the step.

§Contract

  • Zero cost when nobody listens. A client built without a handle, or one whose handle has no live subscriber, never constructs an event: TransferEvents::emit takes a closure and calls it only when a receiver exists. The disabled path is one branch.

  • A transfer never waits on its observer. The channel is a bounded [tokio::sync::broadcast]: a subscriber that falls more than capacity events behind reads RecvError::Lagged with the count it missed, and the transfer carries on. Progress is advisory; the transfer’s result is the value its call returns.

  • Deterministic order. One transfer’s events arrive in the order its state machine took the steps, so a scripted fault schedule produces the same sequence every run. Events carry the blob’s content address, so a subscriber watching several concurrent transfers through one handle can tell them apart.

  • Replayable. An event serializes to one JSON object and parses back to the same value, so a recorded stream replays into a progress UI exactly as it was published.

Events describe the transfer, never its contents: offsets, sizes, content addresses and session ids, no plaintext and no key material.

Structs§

TransferEvents
The handle a transfer publishes its TransferEvents through.

Enums§

RetryReason
Why a chunk is being sent again, or from a different offset than the last acknowledgement.
TransferEvent
One step of a transfer.

Constants§

DEFAULT_CAPACITY
The capacity TransferEvents::default_channel uses: room for a few seconds of chunk traffic on a fast link before a stalled subscriber starts lagging.