Browse Source

Moved SyncResult

github_actions
daladim 4 years ago
parent
commit
38fd04c3a4
  1. 32
      src/provider/mod.rs
  2. 30
      src/provider/sync_progress.rs

32
src/provider.rs → 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.
///

30
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);
}
}
Loading…
Cancel
Save