pub struct Task {
pub id: usize,
pub description: String,
pub total: Option<f64>,
pub completed: f64,
pub visible: bool,
pub start_time: Instant,
pub fields: HashMap<String, String>,
}Expand description
A tracked task within a Progress display.
Fields§
§id: usize§description: String§total: Option<f64>§completed: f64§visible: bool§start_time: Instant§fields: HashMap<String, String>Implementations§
Source§impl Task
impl Task
Sourcepub fn new(
id: usize,
description: impl Into<String>,
total: Option<f64>,
) -> Self
pub fn new( id: usize, description: impl Into<String>, total: Option<f64>, ) -> Self
Create a new Task with the given id, description, and optional total.
Sourcepub fn progress(&self) -> f64
pub fn progress(&self) -> f64
Return the progress fraction (0.0–1.0), or 0.0 if no total is set.
Sourcepub fn time_remaining(&self) -> Option<Duration>
pub fn time_remaining(&self) -> Option<Duration>
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Check if the task is finished (completed >= total).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Task
impl RefUnwindSafe for Task
impl Send for Task
impl Sync for Task
impl Unpin for Task
impl UnsafeUnpin for Task
impl UnwindSafe for Task
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more