use std::cell::RefCell;
use std::rc::Rc;
use std::ffi::OsString;
use std::fmt::Debug;
pub trait ProgressMultiline {
fn create(&mut self, message: String, total_files: u64) -> Rc<RefCell<dyn ProgressIndicator>>;
fn update_dir(&self, new_dir: OsString);
fn finalise(&self);
fn debug_string(&self) -> String;
}
impl Debug for dyn ProgressMultiline {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "Progress indicator for Adding Dir: {}", self.debug_string())
}
}
pub trait ProgressIndicator {
fn create(&mut self, message: String, total_iterations: u64);
fn update(&self, iterations_done: u64);
fn finalise(&self);
fn debug_string(&self) -> String;
}
impl Debug for dyn ProgressIndicator {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "Progress indicator: {}", self.debug_string())
}
}
pub struct NoProgressIndicator {}
impl ProgressIndicator for NoProgressIndicator {
fn create(&mut self, _message: String, _total_iterations: u64) {}
fn update(&self, _iterations_done: u64) {}
fn finalise(&self) {}
fn debug_string(&self) -> String {
"No Progress Bar".to_string()
}
}
pub struct NoProgressMultiline {}
impl ProgressMultiline for NoProgressMultiline {
fn create(
&mut self,
_message: String,
_total_iterations: u64,
) -> Rc<RefCell<dyn ProgressIndicator>> {
Rc::new(RefCell::new(NoProgressIndicator {}))
}
fn update_dir(&self, _new_dir: OsString) {}
fn finalise(&self) {}
fn debug_string(&self) -> String {
"No progress add dir.".to_string()
}
}