pub struct ProgressBar {
pub timeout: Duration,
pub update_interval: Duration,
pub failed_str: String,
pub done_str: String,
pub show_result: bool,
}Expand description
A ProgressBar that can be rendered in a telegram message. This calls a long running async
task and shows a progress bar while the task is running. The progress bar is updated every
update_interval seconds. If the task completes before the timeout then the progress bar
is replaced with a checkmark. If the task fails, then the progress bar is replaced with a
cross.
Fields§
§timeout: DurationThe timeout for the progress bar. If the task completes before this timeout, then the progress bar is replaced with a checkmark.
update_interval: DurationThe update interval for the progress bar. The progress bar is updated every
update_interval seconds.
failed_str: StringThe string to show when the task fails.
done_str: StringThe string to show when the task completes successfully.
show_result: boolIf true, then show the result of the task after the progress bar.
Implementations§
Source§impl ProgressBar
impl ProgressBar
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set the timeout for the progress bar. If the task completes before this timeout, then the progress bar is replaced with a checkmark.
Sourcepub fn with_update_interval(self, update_interval: Duration) -> Self
pub fn with_update_interval(self, update_interval: Duration) -> Self
Set the update interval for the progress bar. The progress bar is updated every
update_interval seconds.
Sourcepub async fn start<F, R>(&self, e: &Event, f: F) -> Result<R>
pub async fn start<F, R>(&self, e: &Event, f: F) -> Result<R>
Start the progress bar. This calls the async function f and shows a progress bar while
the task is running. The progress bar is updated every update_interval seconds. If the
task completes before the timeout then the progress bar is replaced with a checkmark.
If the task fails, then the progress bar is replaced with a cross.
If show_result is true, then the result of the task is shown after the progress bar.
Returns the result of the task.
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