stati/isbar/
mod.rs

1mod manager_interface;
2pub mod subsets;
3
4pub use manager_interface::IsBarManagerInterface;
5
6/// How the bar is handled when it is completed ([`done`] is called)
7///
8/// [`done`]: IsBar::done
9#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
10pub enum BarCloseMethod {
11    /// Print the bar one last time, then cease tracking it.
12    /// The bar will be moved after all currently tracked bars.
13    LeaveBehind,
14    /// Delete the bar, clearing it from the screen.
15    Clear,
16}
17
18/// Basic API of a progress bar,
19/// providing methods required for all progress bars
20///
21/// this does NOT encompass all things a bar needs, and you **should** add more methods
22/// for setting progress, initiating the bar, etc.
23pub trait IsBar {
24    /// Finishes the [`Bar`], allowing it to be finalized and dropped by the manager according to
25    /// the close method returned by [`close_method`].
26    /// The bar should not be used after this is called.
27    ///
28    /// [`Bar`]: IsBar
29    /// [`close_method`]: IsBar::close_method
30    fn done(&mut self);
31
32    /// Checks if the [`Bar`] is done ([`IsBar::done`] as been called)
33    ///
34    /// [`Bar`]: IsBar
35    fn is_done(&self) -> bool;
36
37    /// Formats the [`Bar`] into a string. this is generaly only used by the [`BarManager`]
38    ///
39    /// [`Bar`]: IsBar
40    /// [`BarManager`]: crate::manager::BarManager
41    fn display(&mut self) -> String;
42
43    /// Returns how the bar should be handled by the [`BarManager`] after [`done`] is called
44    ///
45    /// this is for internal use
46    ///
47    /// [`done`]: IsBar::done
48    /// [`BarManager`]: crate::manager::BarManager
49    fn close_method(&self) -> BarCloseMethod;
50}