use alux_sdk::trait_algebra;
use derive_new::new;
use std::path::PathBuf;
#[trait_algebra(derive(Clone, Debug, PartialEq, Eq))]
pub trait DownloadObservation {
fn progress(&self, progress: DownloadProgress);
fn terminal(&self, event: DownloadEvent);
}
#[derive(Clone, Debug, PartialEq, Eq, new)]
pub struct DownloadProgress {
pub destination: PathBuf,
pub downloaded: u64,
pub total: Option<u64>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum DownloadEvent {
Succeeded {
destination: PathBuf,
bytes: u64,
},
Failed {
destination: PathBuf,
message: String,
},
}