Moved SyncResult

This commit is contained in:
daladim 2021-10-08 23:02:37 +02:00
parent e563cb3b2f
commit 38fd04c3a4
2 changed files with 32 additions and 30 deletions

View file

@ -10,36 +10,8 @@ use crate::traits::CompleteCalendar;
use crate::item::SyncStatus; use crate::item::SyncStatus;
use crate::calendar::CalendarId; use crate::calendar::CalendarId;
/// A counter of errors that happen during a sync mod sync_progress;
struct SyncResult { use sync_progress::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);
}
}
/// A data source that combines two `CalDavSource`s, which is able to sync both sources. /// A data source that combines two `CalDavSource`s, which is able to sync both sources.
/// ///

View file

@ -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);
}
}