Expand description
Progress event emission helpers for transfers.
§Design
emit_progress throttles emissions to at most one per 250 ms or per
256 KB transferred, whichever condition is met first. This avoids flooding
the IPC channel while still giving the frontend a responsive progress bar.
emit_state is unthrottled — state transitions (Queued → Running → Done /
Failed / Canceled) must always reach the frontend.
§OCP contract
The same helpers are reused for uploads (task 32) — the throttle logic lives
in one place and is called identically from both download.rs and
upload.rs.
Structs§
- Progress
Throttle - Tracks when the last progress event was emitted so
emit_progresscan apply the 250 ms / 256 KB throttle. - Transfer
Progress Payload - Payload for
transfer:progress. - Transfer
State Payload - Payload for
transfer:state.
Constants§
- PROGRESS_
THROTTLE_ BYTES - Minimum bytes transferred between progress events.
- PROGRESS_
THROTTLE_ MS - Minimum milliseconds between progress events for one transfer.
Functions§
- emit_
progress - Emit a
transfer:progressevent if the throttle gate is open. - emit_
state - Emit a
transfer:stateevent (unthrottled). Useemit_state_with_erroronFailedtransitions to attach the underlyingAppErrorto the payload so the frontend can render the failure reason. - emit_
state_ with_ error - Emit a
transfer:stateevent with an optionalAppErrorattached.