pub struct Progress { /* private fields */ }Implementations§
Source§impl Progress
impl Progress
pub fn new( columns: Vec<Box<dyn ProgressColumn>>, live_options: LiveOptions, disable: bool, expand: bool, ) -> Self
pub fn with_console( columns: Vec<Box<dyn ProgressColumn>>, console: Console<Stdout>, live_options: LiveOptions, disable: bool, expand: bool, ) -> Self
Sourcepub fn new_default(
live_options: LiveOptions,
disable: bool,
expand: bool,
show_speed: bool,
) -> Self
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.
pub fn start(&mut self) -> Result<()>
pub fn stop(&mut self) -> Result<()>
pub fn refresh(&self) -> Result<()>
pub fn add_task( &self, description: &str, start: bool, total: Option<f64>, completed: f64, visible: bool, ) -> TaskID
pub fn remove_task(&self, task_id: TaskID)
pub fn start_task(&self, task_id: TaskID)
pub fn stop_task(&self, task_id: TaskID)
pub fn advance(&self, task_id: TaskID, advance: f64)
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>>, )
pub fn update_task( &self, task_id: TaskID, total: Option<Option<f64>>, completed: Option<f64>, description: Option<String>, visible: Option<bool>, )
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>>, )
pub fn track<'a, I>(
&'a self,
iter: I,
task_id: TaskID,
update_period: Duration,
) -> ProgressIterator<'a, I::IntoIter> ⓘwhere
I: IntoIterator,
Sourcepub 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,
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.
pub fn track_sequence<'a, I>(
&'a self,
sequence: I,
config: TrackConfig,
) -> ProgressIterator<'a, I::IntoIter> ⓘwhere
I: IntoIterator,
pub fn print<R: Renderable + ?Sized>( &self, renderable: &R, style: Option<Style>, justify: Option<JustifyMethod>, overflow: Option<OverflowMethod>, no_wrap: bool, end: &str, ) -> Result<()>
pub fn log<R: Renderable + ?Sized>( &self, renderable: &R, file: Option<&str>, line: Option<u32>, ) -> Result<()>
Source§impl Progress
impl Progress
Sourcepub fn wrap_file<'a, R: Read>(
&'a self,
reader: R,
total: Option<u64>,
description: &str,
) -> ProgressReader<'a, R> ⓘ
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 implementingRead).total- Total number of bytes expected. PassNonefor 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();Sourcepub fn wrap_file_with_task<'a, R: Read>(
&'a self,
reader: R,
task_id: TaskID,
total: Option<u64>,
) -> ProgressReader<'a, R> ⓘ
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.
Sourcepub fn open<'a, P: AsRef<Path>>(
&'a self,
path: P,
description: &str,
) -> Result<ProgressReader<'a, File>>
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();Sourcepub fn open_with_task<'a, P: AsRef<Path>>(
&'a self,
path: P,
task_id: TaskID,
) -> Result<ProgressReader<'a, File>>
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.