pub struct ProgressBar { /* private fields */ }Expand description
A thread safe, thread stable progress bar, abstracted for any frontend
Implementations§
Source§impl ProgressBar
impl ProgressBar
Sourcepub fn flush(&self)
pub fn flush(&self)
Waits until the flush is processed, allowing you to wait until all previous events have been processed
§Panics
Panics if the internal GLOBAL_SENDER thread cannot be communicated with. This usually signals critical failure somewhere
Sourcepub fn get_max(&self) -> usize
pub fn get_max(&self) -> usize
Gets the max value of the internal ProgressHandle
§Notes
While this will return the correct max value at time of call, In multi-threaded contexts, this max may have already changed by the time it has been used
Sourcepub fn get_value(&self) -> usize
pub fn get_value(&self) -> usize
Gets the value of the internal ProgressHandle
§Notes
While this will return the correct value at time of call, In multi-threaded contexts, this value may have already changed by the time it has been used
Sourcepub fn increment(&self)
pub fn increment(&self)
Increments the value of a progress bar by 1
§Panics
Panics if the internal GLOBAL_SENDER thread cannot be communicated with. This usually signals critical failure somewhere
Sourcepub fn increment_and_run<P, Q>(&self, pre: Option<P>, post: Option<Q>)
pub fn increment_and_run<P, Q>(&self, pre: Option<P>, post: Option<Q>)
Increments the value of the progress bar by 1 and runs a pre-write and post-write closure
The pre closure, if some, will run before the value is incremented
The post closure, if some, will run after the value is incremented, and before ProgressRenderer::on_update() method is run
§Panics
Panics if the internal GLOBAL_SENDER thread cannot be communicated with. This usually signals critical failure somewhere
Sourcepub fn new(
value: usize,
max: usize,
renderer: Arc<dyn ProgressRenderer>,
) -> Self
pub fn new( value: usize, max: usize, renderer: Arc<dyn ProgressRenderer>, ) -> Self
Creates a new progress bar instance using the renderer
This progress bar can safely be shared and updated between threads
Sourcepub fn set_max(&self, max: usize)
pub fn set_max(&self, max: usize)
Sets the max-value of the progress bar
§Panics
Panics if the internal GLOBAL_SENDER thread cannot be communicated with. This usually signals critical failure somewhere
Sourcepub fn set_max_and_run<P, Q>(&self, max: usize, pre: Option<P>, post: Option<Q>)
pub fn set_max_and_run<P, Q>(&self, max: usize, pre: Option<P>, post: Option<Q>)
Sets the max-value of the progress bar and runs a pre-write and post-write closure
The pre closure, if some, will run before the value is incremented
The post closure, if some, will run after the value is incremented, and before ProgressRenderer::on_update() method is run
§Panics
Panics if the internal GLOBAL_SENDER thread cannot be communicated with. This usually signals critical failure somewhere
§Notes
If the any of the input closures panic, it will not kill the thread, it will instead log the error and ignore it
Sourcepub fn set_value(&self, value: usize)
pub fn set_value(&self, value: usize)
Sets the value of the progress bar
§Panics
Panics if the internal GLOBAL_SENDER thread cannot be communicated with. This usually signals critical failure somewhere
Sourcepub fn set_value_and_run<P, Q>(
&self,
value: usize,
pre: Option<P>,
post: Option<Q>,
)
pub fn set_value_and_run<P, Q>( &self, value: usize, pre: Option<P>, post: Option<Q>, )
Sets the value of the progress bar and runs a pre-write and post-write closure
The pre closure, if some, will run before the value is incremented
The post closure, if some, will run after the value is incremented, and before ProgressRenderer::on_update() method is run
§Panics
Panics if the internal GLOBAL_SENDER thread cannot be communicated with. This usually signals critical failure somewhere
§Notes
If the any of the input closures panic, it will not kill the thread, it will instead log the error and ignore it
Sourcepub fn update(&self)
pub fn update(&self)
Forces the ProgressRenderer to upate with the new values
§Panics
Panics if the progress bars handling thread cannot be communicated with.
Sourcepub fn set_label(&self, label: &str)
pub fn set_label(&self, label: &str)
Calls the ProgressRenderer::set_label() function for the held ProgressRenderer
Sourcepub fn notify(&self, message: impl ToString)
pub fn notify(&self, message: impl ToString)
Tells the handling thread to call the ProgressRenderer::on_notify() function for the held ProgressRenderer
§Panics
Panics if the progress bars handling thread cannot be communicated with.
Trait Implementations§
Source§impl Clone for ProgressBar
impl Clone for ProgressBar
Source§fn clone(&self) -> ProgressBar
fn clone(&self) -> ProgressBar
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more