fast_pull/base/event.rs
1//! Download lifecycle events emitted on the
2//! [`event_chain`](crate::DownloadResult::event_chain).
3
4use crate::ProgressEntry;
5
6/// Numeric identifier assigned to each worker thread/task.
7pub type WorkerId = usize;
8
9/// Events emitted during a download session, received via [`DownloadResult::event_chain`](crate::DownloadResult::event_chain).
10///
11/// Each variant records a state change: pulling, pushing, progress, errors, or completion.
12///
13/// Deliberately **not** `#[non_exhaustive]`: `fast-down`'s forwarding layer
14/// matches it exhaustively, so a new variant forces that layer to be updated
15/// rather than letting the event be dropped silently.
16#[derive(Debug)]
17pub enum Event<PullError, PushError> {
18 /// A worker started fetching its assigned range (carries its id).
19 Pulling(WorkerId),
20 /// A worker failed to fetch its range.
21 PullError(WorkerId, PullError),
22 /// A worker's fetch exceeded its time budget and was aborted.
23 PullTimeout(WorkerId),
24 /// A worker pulled a range into memory (not yet written).
25 PullProgress(WorkerId, ProgressEntry),
26 /// A worker is handing a pulled range to the sink.
27 Pushing(WorkerId, ProgressEntry),
28 /// A worker failed to write a range to the sink.
29 PushError(WorkerId, ProgressEntry, PushError),
30 /// A range was successfully written to the sink.
31 PushProgress(ProgressEntry),
32 /// The sink is being flushed.
33 Flushing,
34 /// Flushing the sink failed.
35 FlushError(PushError),
36 /// A worker completed its assigned range and exited.
37 Finished(WorkerId),
38}