Skip to main content

DownloadEvent

Enum DownloadEvent 

Source
pub enum DownloadEvent {
    QueueSnapshot {
        items: Vec<DownloadSummary>,
        max_size: u32,
    },
    DownloadStarted {
        id: String,
        shard_index: Option<u32>,
        total_shards: Option<u32>,
    },
    DownloadProgress {
        id: String,
        downloaded: u64,
        total: u64,
        speed_bps: Option<f64>,
        eta_seconds: Option<f64>,
        percentage: f64,
    },
    ShardProgress {
        id: String,
        shard_index: u32,
        total_shards: u32,
        shard_filename: String,
        shard_downloaded: u64,
        shard_total: u64,
        aggregate_downloaded: u64,
        aggregate_total: u64,
        speed_bps: Option<f64>,
        eta_seconds: Option<f64>,
        percentage: f64,
    },
    DownloadCompleted {
        id: String,
        message: Option<String>,
    },
    DownloadFailed {
        id: String,
        error: String,
    },
    DownloadCancelled {
        id: String,
    },
    DownloadStatusChanged {
        id: String,
        status: DownloadStatus,
    },
    DownloadNotice {
        id: String,
        message: String,
    },
    QueueRunComplete {
        summary: QueueRunSummary,
    },
}
Expand description

Single discriminated union for all download events.

The frontend handles this as a TypeScript discriminated union:

type DownloadEvent =
  | { type: "queue_snapshot"; items: DownloadSummary[]; max_size: number }
  | { type: "download_started"; id: string; shard_index?: number; total_shards?: number }
  | { type: "download_progress"; id: string; downloaded: number; total: number;
      speed_bps?: number; eta_seconds?: number; percentage: number }
  | { type: "shard_progress"; id: string; shard_index: number;
      speed_bps?: number; eta_seconds?: number; ... }
  | { type: "download_completed"; id: string }
  | { type: "download_failed"; id: string; error: string }
  | { type: "download_cancelled"; id: string }
  | { type: "download_notice"; id: string; message: string };

speed_bps and eta_seconds are optional and omitted when unknown — a download that has just started has no meaningful rate yet. Renderers must show a placeholder for the absent case rather than substituting 0, and must never compute a rate of their own from successive downloaded values; the manager’s RateEstimator is the only source. The mirrored TypeScript declaration lives in src/services/transport/types/events.ts.

Variants§

§

QueueSnapshot

Snapshot of the entire queue state.

Fields

§items: Vec<DownloadSummary>

All items currently in the queue.

§max_size: u32

Maximum queue capacity.

§

DownloadStarted

A download has started.

Fields

§id: String

Canonical ID of the download.

§shard_index: Option<u32>

Current shard index (0-based), present only for sharded downloads.

§total_shards: Option<u32>

Total number of shards, present only for sharded downloads.

§

DownloadProgress

Progress update for a non-sharded download.

Fields

§id: String

Canonical ID of the download.

§downloaded: u64

Bytes downloaded so far.

§total: u64

Total bytes to download.

§speed_bps: Option<f64>

Current download speed in bytes per second.

Absent until the estimator has warmed up. This is deliberately not 0.0: zero is a real reading meaning “stalled”, and conflating the two is what rendered ETA: 0s on a healthy download.

§eta_seconds: Option<f64>

Estimated time remaining in seconds; absent when not yet known.

§percentage: f64

Progress percentage (0.0 - 100.0).

§

ShardProgress

Progress update for a sharded download.

Fields

§id: String

Canonical ID of the download (group ID).

§shard_index: u32

Current shard index (0-based).

§total_shards: u32

Total number of shards.

§shard_filename: String

Filename of the current shard.

§shard_downloaded: u64

Bytes downloaded for current shard.

§shard_total: u64

Total bytes for current shard.

§aggregate_downloaded: u64

Aggregate bytes downloaded across all shards.

§aggregate_total: u64

Aggregate total bytes across all shards.

§speed_bps: Option<f64>

Current download speed in bytes per second; absent until known.

Measured across the whole shard group, not reset per shard.

§eta_seconds: Option<f64>

Estimated time remaining in seconds; absent when not yet known.

§percentage: f64

Aggregate progress percentage (0.0 - 100.0).

§

DownloadCompleted

Download completed successfully.

Fields

§id: String

Canonical ID of the download.

§message: Option<String>

Optional success message.

§

DownloadFailed

Download failed with an error.

Fields

§id: String

Canonical ID of the download.

§error: String

Error message describing what went wrong.

§

DownloadCancelled

Download was cancelled by the user.

Fields

§id: String

Canonical ID of the download.

§

DownloadStatusChanged

Lifecycle status transition for a download (e.g. DownloadingFinalizingRegistering).

Emitted at the boundaries between phases so transports can render a non-frozen state while the manager is verifying bytes and writing the model row to the database. Terminal states (Completed, Failed, Cancelled) keep their dedicated event variants.

Fields

§id: String

Canonical ID of the download.

§status: DownloadStatus

New status of the download.

§

DownloadNotice

A transient, human-readable note about work happening for this download that produces no byte progress of its own — e.g. building the first-run Python environment for the fast downloader.

Unlike Self::DownloadStatusChanged this carries free-form text rather than a fixed DownloadStatus and is not persisted; it exists purely so the renderer has something to show instead of looking frozen while setup work happens before the first progress event.

Fields

§id: String

Canonical ID of the download.

§message: String

Human-readable note to display in place of progress.

§

QueueRunComplete

Queue run completed (all downloads in the queue finished).

Emitted when the download queue transitions from busy → idle, providing a complete summary of all artifacts that were processed during the run.

Fields

§summary: QueueRunSummary

Complete summary of the queue run.

Implementations§

Source§

impl DownloadEvent

Source

pub const fn queue_snapshot(items: Vec<DownloadSummary>, max_size: u32) -> Self

Create a queue snapshot event.

Source

pub fn started(id: impl Into<String>) -> Self

Create a download started event.

Source

pub fn started_shard( id: impl Into<String>, shard_index: u32, total_shards: u32, ) -> Self

Create a download started event with shard information.

Source

fn percent_of(downloaded: u64, total: u64) -> f64

Percentage complete, clamped to 0-100.

Source

pub fn progress( id: impl Into<String>, downloaded: u64, total: u64, speed_bps: Option<f64>, eta_seconds: Option<f64>, ) -> Self

Create a non-sharded progress event.

speed_bps and eta_seconds come from the manager’s RateEstimator — this constructor deliberately does not derive an ETA of its own. Two estimators for one number is how the CLI and the GUI ended up disagreeing.

Source

pub fn shard_progress( id: impl Into<String>, shard_index: u32, total_shards: u32, shard_filename: impl Into<String>, shard_downloaded: u64, shard_total: u64, aggregate_downloaded: u64, aggregate_total: u64, speed_bps: Option<f64>, eta_seconds: Option<f64>, ) -> Self

Create a sharded progress event.

See progress on where the rate values come from.

Source

pub fn completed( id: impl Into<String>, message: Option<impl Into<String>>, ) -> Self

Create a download completed event.

Source

pub fn failed(id: impl Into<String>, error: impl Into<String>) -> Self

Create a download failed event.

Source

pub fn cancelled(id: impl Into<String>) -> Self

Create a download cancelled event.

Source

pub fn status_changed(id: impl Into<String>, status: DownloadStatus) -> Self

Create a status-changed event for non-terminal lifecycle transitions.

Source

pub const fn queue_run_complete(summary: QueueRunSummary) -> Self

Create a queue run complete event.

Source

pub fn id(&self) -> Option<&str>

Get the download ID from any event type.

Source

pub const fn event_name(&self) -> &'static str

Get the event name for wire protocols.

This provides consistent event naming for Tauri and SSE transports. Note: Both ShardProgress and DownloadProgress use “download:progress” as the channel name; differentiation happens via the type discriminator.

Trait Implementations§

Source§

impl Clone for DownloadEvent

Source§

fn clone(&self) -> DownloadEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DownloadEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DownloadEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for DownloadEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,