1use fast_down::ProgressEntry;
2use std::fmt::Debug;
3
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub enum Event {
7 PrefetchError(String),
8 Pulling(usize),
9 PullError(usize, String),
10 PullTimeout(usize),
11 PullProgress(usize, ProgressEntry),
12 PushError(usize, String),
13 PushProgress(usize, ProgressEntry),
14 FlushError(String),
15 Finished(usize),
16}
17
18impl<RE: Debug, WE: Debug> From<&fast_down::Event<RE, WE>> for Event {
19 fn from(event: &fast_down::Event<RE, WE>) -> Self {
20 match event {
21 fast_down::Event::Pulling(id) => Self::Pulling(*id),
22 fast_down::Event::PullError(id, e) => Self::PullError(*id, format!("{e:?}")),
23 fast_down::Event::PullTimeout(id) => Self::PullTimeout(*id),
24 fast_down::Event::PullProgress(id, range) => Self::PullProgress(*id, range.clone()),
25 fast_down::Event::PushError(id, e) => Self::PushError(*id, format!("{e:?}")),
26 fast_down::Event::PushProgress(id, range) => Self::PushProgress(*id, range.clone()),
27 fast_down::Event::FlushError(e) => Self::FlushError(format!("{e:?}")),
28 fast_down::Event::Finished(id) => Self::Finished(*id),
29 }
30 }
31}