serde_hkx_features/progress.rs
1//! Progress bar trait
2
3use std::path::Path;
4
5/// A trait for handling progress updates during a file verification process.
6pub trait ProgressHandler {
7 /// Called when no files are found in the directory.
8 ///
9 /// The default implementation does nothing.
10 #[inline]
11 fn on_empty(&self) {}
12
13 /// Sets the total number of items to process.
14 ///
15 /// The default implementation does nothing.
16 #[inline]
17 fn on_set_total(&mut self, total: usize) {
18 let _ = total;
19 }
20
21 /// Increments the progress by a specified amount.
22 ///
23 /// The default implementation does nothing.
24 #[inline]
25 fn inc(&self, progress: u64) {
26 let _ = progress;
27 }
28
29 /// Increments success count.
30 ///
31 /// The default implementation does nothing.
32 #[inline]
33 fn success_inc(&self, progress: u64) {
34 let _ = progress;
35 }
36
37 /// Increments failure count.
38 ///
39 /// The default implementation does nothing.
40 #[inline]
41 fn failure_inc(&self, progress: u64) {
42 let _ = progress;
43 }
44
45 /// The path for the current progress state.
46 ///
47 /// The default implementation does nothing.
48 #[inline]
49 fn on_processing_path(&self, path: &Path) {
50 let _ = path; // No-op by default
51 }
52
53 /// Called when all files have been processed.
54 ///
55 /// The default implementation does nothing.
56 #[inline]
57 fn on_finish(&self) {}
58}
59
60/// A default implementation of the `ProgressHandler` trait that does nothing.
61#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord)]
62pub struct DefaultProgressMonitor;
63impl ProgressHandler for DefaultProgressMonitor {}