kdam 0.6.4

A console progress bar library for Rust. (inspired by tqdm & rich.progress)
Documentation
use std::io::{Result, Write};

/// Comman progress bar functionalities shared between different types of progress bars.
pub trait BarExt {
    /// Clear current progress bar display.
    ///
    /// Returns `Err`, if writing to handle fails.
    fn clear(&mut self) -> Result<()>;

    /// Take input via progress bar (without overlaping with bar(s)).
    ///
    /// Returns `Err`, if reading from stdin handle fails.
    fn input<T: Into<String>>(&mut self, text: T) -> Result<String>;

    /// Force refresh current progress bar display.
    ///
    /// Returns `Err`, if writing to handle fails.
    fn refresh(&mut self) -> Result<()>;

    /// Render progress bar text.
    fn render(&mut self) -> String;

    /// Resets counter to 0 for repeated use.
    ///
    /// Consider combining with `leave = true`.
    fn reset(&mut self, total: Option<usize>);

    /// Manually update the progress bar, useful for streams such as reading files.
    ///
    /// Returns whether an update was triggered or not depending on constraints.
    /// Returns `Err`, if writing to handle fails.
    fn update(&mut self, n: usize) -> Result<bool>;

    /// Set counter value instead of incrementing counter through [update](Self::update) method.
    ///
    /// Returns wheter a update was triggered or not depending on constraints.
    /// Returns `Err`, if writing to handle fails.
    fn update_to(&mut self, n: usize) -> Result<bool>;

    /// Print a message via progress bar (without overlaping with bar(s)).
    ///
    /// Returns `Err`, if writing to handle fails.
    fn write<T: Into<String>>(&mut self, text: T) -> Result<()>;

    /// Write progress bar rendered text to a writer (useful for writing files).
    ///
    /// If `n` is supplied then this method behaves like [update](Self::update) method.
    ///
    /// Returns whether a update was triggered or not depending on constraints.
    /// Returns `Err`, if writing to handle fails.
    ///
    /// # Example
    ///
    /// Using [write_to](Self::write_to) as [update_to](Self::update_to).
    ///
    /// ```
    /// use kdam::{tqdm, BarExt};
    /// use std::{fs::File, io::Write};
    ///
    /// let mut pb = tqdm!(total = 100, animation = "ascii");
    /// let mut f = File::create("kdam-logs.txt").unwrap();
    ///
    /// for i in 1..101 {
    ///     pb.counter = i;
    ///     pb.write_to(&mut f, Some(0));
    /// }
    /// ```
    fn write_to<T: Write>(&mut self, writer: &mut T, n: Option<usize>) -> Result<bool>;
}