pub struct TaskProgress {
pub processed: u64,
pub total: Option<u64>,
pub unit: ProgressUnit,
}Expand description
Progress counters for a running task.
Fields§
§processed: u64Number of items processed so far.
total: Option<u64>Total number of items, if known.
unit: ProgressUnitThe unit of measurement.
Implementations§
Source§impl TaskProgress
impl TaskProgress
Sourcepub fn new(unit: ProgressUnit) -> Self
pub fn new(unit: ProgressUnit) -> Self
Create a new progress tracker with zero items processed.
Sourcepub fn fraction(&self) -> Option<f64>
pub fn fraction(&self) -> Option<f64>
Returns the completion fraction in [0.0, 1.0], or None if
the total is unknown or zero.
Counters above 2^52 lose precision in the conversion, which is acceptable for a display fraction.
Sourcepub fn aggregate<'a>(
progress: impl IntoIterator<Item = &'a TaskProgress>,
) -> Option<Self>
pub fn aggregate<'a>( progress: impl IntoIterator<Item = &'a TaskProgress>, ) -> Option<Self>
Aggregate progress counters with the same unit.
Returns None when the iterator is empty or when any item
uses a different unit. Unknown totals are preserved: if any
child total is unknown then the aggregate total is unknown.
Trait Implementations§
Source§impl Clone for TaskProgress
impl Clone for TaskProgress
Source§fn clone(&self) -> TaskProgress
fn clone(&self) -> TaskProgress
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TaskProgress
impl Debug for TaskProgress
Source§impl<'de> Deserialize<'de> for TaskProgress
impl<'de> Deserialize<'de> for TaskProgress
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for TaskProgress
Source§impl PartialEq for TaskProgress
impl PartialEq for TaskProgress
Source§impl Serialize for TaskProgress
impl Serialize for TaskProgress
impl StructuralPartialEq for TaskProgress
Auto Trait Implementations§
impl Freeze for TaskProgress
impl RefUnwindSafe for TaskProgress
impl Send for TaskProgress
impl Sync for TaskProgress
impl Unpin for TaskProgress
impl UnsafeUnpin for TaskProgress
impl UnwindSafe for TaskProgress
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