SyncEvent is more usable

This commit is contained in:
daladim 2021-11-04 09:01:25 +01:00
parent d8c89ec727
commit 7d09d72175

View file

@ -3,6 +3,7 @@
use std::fmt::{Display, Error, Formatter}; use std::fmt::{Display, Error, Formatter};
/// An event that happens during a sync /// An event that happens during a sync
#[derive(Clone, Debug)]
pub enum SyncEvent { pub enum SyncEvent {
/// Sync has not started /// Sync has not started
NotStarted, NotStarted,
@ -18,8 +19,8 @@ impl Display for SyncEvent {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
match self { match self {
SyncEvent::NotStarted => write!(f, "Not started"), SyncEvent::NotStarted => write!(f, "Not started"),
SyncEvent::Started => write!(f, "Sync has started"), SyncEvent::Started => write!(f, "Sync has started..."),
SyncEvent::InProgress{calendar, details} => write!(f, "[{}] {}", calendar, details), SyncEvent::InProgress{calendar, details} => write!(f, "[{}] {}...", calendar, details),
SyncEvent::Finished{success} => match success { SyncEvent::Finished{success} => match success {
true => write!(f, "Sync successfully finished"), true => write!(f, "Sync successfully finished"),
false => write!(f, "Sync finished with errors"), false => write!(f, "Sync finished with errors"),