diff --git a/crates/rustic_core/src/lib.rs b/crates/rustic_core/src/lib.rs index b7d5389e4..d4f082c70 100644 --- a/crates/rustic_core/src/lib.rs +++ b/crates/rustic_core/src/lib.rs @@ -130,7 +130,7 @@ pub use crate::{ indexer::Indexer, IndexBackend, IndexEntry, IndexedBackend, ReadIndex, }, - progress::{Progress, ProgressBars}, + progress::{NoProgress, NoProgressBars, Progress, ProgressBars}, repofile::{ configfile::ConfigFile, indexfile::{IndexBlob, IndexFile, IndexPack}, diff --git a/crates/rustic_core/src/progress.rs b/crates/rustic_core/src/progress.rs index fdd9af51a..02a4d32b9 100644 --- a/crates/rustic_core/src/progress.rs +++ b/crates/rustic_core/src/progress.rs @@ -15,3 +15,32 @@ pub trait ProgressBars { fn progress_hidden(&self) -> Self::P; fn progress_bytes(&self, prefix: impl Into>) -> Self::P; } + +#[derive(Clone)] +pub struct NoProgress; +impl Progress for NoProgress { + fn is_hidden(&self) -> bool { + true + } + fn set_length(&self, _len: u64) {} + fn set_title(&self, _title: &'static str) {} + fn inc(&self, _inc: u64) {} + fn finish(&self) {} +} + +pub struct NoProgressBars; +impl ProgressBars for NoProgressBars { + type P = NoProgress; + fn progress_spinner(&self, _prefix: impl Into>) -> Self::P { + NoProgress + } + fn progress_counter(&self, _prefix: impl Into>) -> Self::P { + NoProgress + } + fn progress_hidden(&self) -> Self::P { + NoProgress + } + fn progress_bytes(&self, _prefix: impl Into>) -> Self::P { + NoProgress + } +}