use std::{fmt::Display, io, sync::mpsc::SendError}; use serde_with::SerializeDisplay; #[derive(SerializeDisplay)] pub enum DownloadManagerError { IOError(io::Error), SignalError(SendError), } impl Display for DownloadManagerError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { DownloadManagerError::IOError(error) => write!(f, "{}", error), DownloadManagerError::SignalError(send_error) => write!(f, "{}", send_error), } } } impl From> for DownloadManagerError { fn from(value: SendError) -> Self { DownloadManagerError::SignalError(value) } } impl From for DownloadManagerError { fn from(value: io::Error) -> Self { DownloadManagerError::IOError(value) } }