Skip to main content

Progress

Struct Progress 

Source
pub struct Progress { /* private fields */ }

Implementations§

Source§

impl Progress

Source

pub fn new( columns: Vec<Box<dyn ProgressColumn>>, live_options: LiveOptions, disable: bool, expand: bool, ) -> Self

Source

pub fn with_console( columns: Vec<Box<dyn ProgressColumn>>, console: Console<Stdout>, live_options: LiveOptions, disable: bool, expand: bool, ) -> Self

Source

pub fn new_default( live_options: LiveOptions, disable: bool, expand: bool, show_speed: bool, ) -> Self

A convenience constructor matching Rich’s default track() columns: description, bar, percentage, and time remaining.

Source

pub fn start(&mut self) -> Result<()>

Source

pub fn stop(&mut self) -> Result<()>

Source

pub fn refresh(&self) -> Result<()>

Source

pub fn add_task( &self, description: &str, start: bool, total: Option<f64>, completed: f64, visible: bool, ) -> TaskID

Source

pub fn remove_task(&self, task_id: TaskID)

Source

pub fn start_task(&self, task_id: TaskID)

Source

pub fn stop_task(&self, task_id: TaskID)

Source

pub fn advance(&self, task_id: TaskID, advance: f64)

Source

pub fn update( &self, task_id: TaskID, total: Option<Option<f64>>, completed: Option<f64>, advance: Option<f64>, description: Option<String>, visible: Option<bool>, refresh: bool, fields: Option<HashMap<String, String>>, )

Source

pub fn update_task( &self, task_id: TaskID, total: Option<Option<f64>>, completed: Option<f64>, description: Option<String>, visible: Option<bool>, )

Source

pub fn reset( &self, task_id: TaskID, start: bool, total: Option<Option<f64>>, completed: f64, visible: Option<bool>, description: Option<String>, fields: Option<HashMap<String, String>>, )

Source

pub fn track<'a, I>( &'a self, iter: I, task_id: TaskID, update_period: Duration, ) -> ProgressIterator<'a, I::IntoIter>
where I: IntoIterator,

Source

pub fn track_iter<'a, I>( &'a self, iter: I, description: &str, total: Option<f64>, completed: f64, update_period: Duration, ) -> ProgressIterator<'a, I::IntoIter>
where I: IntoIterator,

Create a task and return an iterator that advances it.

Source

pub fn track_sequence<'a, I>( &'a self, sequence: I, config: TrackConfig, ) -> ProgressIterator<'a, I::IntoIter>
where I: IntoIterator,

Source

pub fn print<R: Renderable + ?Sized>( &self, renderable: &R, style: Option<Style>, justify: Option<JustifyMethod>, overflow: Option<OverflowMethod>, no_wrap: bool, end: &str, ) -> Result<()>

Source

pub fn log<R: Renderable + ?Sized>( &self, renderable: &R, file: Option<&str>, line: Option<u32>, ) -> Result<()>

Source§

impl Progress

Source

pub fn tasks(&self) -> Vec<ProgressTask>

Access the task list (snapshot).

Source

pub fn task_ids(&self) -> Vec<TaskID>

List of task IDs in order.

Source

pub fn finished(&self) -> bool

Whether all tasks are complete.

Source§

impl Progress

Source

pub fn wrap_file<'a, R: Read>( &'a self, reader: R, total: Option<u64>, description: &str, ) -> ProgressReader<'a, R>

Wrap a reader to track progress while reading.

This creates a new task and wraps the reader to automatically update progress as data is read.

§Arguments
  • reader - The reader to wrap (any type implementing Read).
  • total - Total number of bytes expected. Pass None for indeterminate.
  • description - Description shown next to the progress bar.
§Example
use std::fs::File;
use std::io::Read;
use rich_rs::Progress;
use rich_rs::live::LiveOptions;

let progress = Progress::new_default(LiveOptions::default(), false, false, false);
let file = File::open("data.bin").unwrap();

let mut reader = progress.wrap_file(file, Some(1024), "Reading data");
let mut buf = Vec::new();
reader.read_to_end(&mut buf).unwrap();
Source

pub fn wrap_file_with_task<'a, R: Read>( &'a self, reader: R, task_id: TaskID, total: Option<u64>, ) -> ProgressReader<'a, R>

Wrap a reader with an existing task.

Similar to wrap_file, but uses an existing task instead of creating a new one. Optionally updates the task’s total.

§Arguments
  • reader - The reader to wrap.
  • task_id - The existing task to update.
  • total - Optional total to set on the task.
Source

pub fn open<'a, P: AsRef<Path>>( &'a self, path: P, description: &str, ) -> Result<ProgressReader<'a, File>>

Open a file with progress tracking.

This is a convenience method that opens a file, determines its size, creates a progress task, and returns a wrapped reader.

§Arguments
  • path - Path to the file to open.
  • description - Description shown next to the progress bar.
§Errors

Returns an error if the file cannot be opened or its metadata cannot be read.

§Example
use std::io::Read;
use rich_rs::Progress;
use rich_rs::live::LiveOptions;

let mut progress = Progress::new_default(LiveOptions::default(), false, false, false);
progress.start().unwrap();

let mut reader = progress.open("large_file.bin", "Processing file").unwrap();
let mut contents = Vec::new();
reader.read_to_end(&mut contents).unwrap();

progress.stop().unwrap();
Source

pub fn open_with_task<'a, P: AsRef<Path>>( &'a self, path: P, task_id: TaskID, ) -> Result<ProgressReader<'a, File>>

Open a file with progress tracking using an existing task.

Similar to open, but uses an existing task instead of creating a new one. The task’s total will be updated to the file size.

§Arguments
  • path - Path to the file to open.
  • task_id - The existing task to update.
§Errors

Returns an error if the file cannot be opened or its metadata cannot be read.

Trait Implementations§

Source§

impl Drop for Progress

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Renderable for Progress

Source§

fn render(&self, console: &Console, options: &ConsoleOptions) -> Segments

Render this object to a sequence of segments.
Source§

fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement

Measure the minimum and maximum width requirements. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.