From 38fd04c3a47951d19cbf646ddf81d3d4dbb0b44c Mon Sep 17 00:00:00 2001 From: daladim Date: Fri, 8 Oct 2021 23:02:37 +0200 Subject: [PATCH] Moved SyncResult --- src/{provider.rs => provider/mod.rs} | 32 ++-------------------------- src/provider/sync_progress.rs | 30 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 30 deletions(-) rename src/{provider.rs => provider/mod.rs} (95%) create mode 100644 src/provider/sync_progress.rs diff --git a/src/provider.rs b/src/provider/mod.rs similarity index 95% rename from src/provider.rs rename to src/provider/mod.rs index aad647e..e9cec70 100644 --- a/src/provider.rs +++ b/src/provider/mod.rs @@ -10,36 +10,8 @@ use crate::traits::CompleteCalendar; use crate::item::SyncStatus; use crate::calendar::CalendarId; -/// A counter of errors that happen during a sync -struct SyncResult { - n_errors: u32, -} -impl SyncResult { - pub fn new() -> Self { - Self { n_errors: 0 } - } - pub fn is_success(&self) -> bool { - self.n_errors == 0 - } - - pub fn error(&mut self, text: &str) { - log::error!("{}", text); - self.n_errors += 1; - } - pub fn warn(&mut self, text: &str) { - log::warn!("{}", text); - self.n_errors += 1; - } - pub fn info(&mut self, text: &str) { - log::info!("{}", text); - } - pub fn debug(&mut self, text: &str) { - log::debug!("{}", text); - } - pub fn trace(&mut self, text: &str) { - log::trace!("{}", text); - } -} +mod sync_progress; +use sync_progress::SyncResult; /// A data source that combines two `CalDavSource`s, which is able to sync both sources. /// diff --git a/src/provider/sync_progress.rs b/src/provider/sync_progress.rs new file mode 100644 index 0000000..1399233 --- /dev/null +++ b/src/provider/sync_progress.rs @@ -0,0 +1,30 @@ +/// A counter of errors that happen during a sync +pub struct SyncResult { + n_errors: u32, +} +impl SyncResult { + pub fn new() -> Self { + Self { n_errors: 0 } + } + pub fn is_success(&self) -> bool { + self.n_errors == 0 + } + + pub fn error(&mut self, text: &str) { + log::error!("{}", text); + self.n_errors += 1; + } + pub fn warn(&mut self, text: &str) { + log::warn!("{}", text); + self.n_errors += 1; + } + pub fn info(&mut self, text: &str) { + log::info!("{}", text); + } + pub fn debug(&mut self, text: &str) { + log::debug!("{}", text); + } + pub fn trace(&mut self, text: &str) { + log::trace!("{}", text); + } +}