pub struct ProgressUpdate { /* private fields */ }Expand description
Represents a single progress update with current status, total, and optional metadata.
This struct contains all the information about the current state of a progress-tracked operation. It is emitted by progress streams and provides methods to query the current progress state.
You typically don’t create instances of this struct directly. Instead, use the progress function
to create progress-tracked tasks, and receive ProgressUpdate instances from the progress stream.
Implementations§
Source§impl ProgressUpdate
impl ProgressUpdate
Sourcepub const fn new(
total: u64,
current: u64,
state: State,
message: Option<String>,
) -> Self
pub const fn new( total: u64, current: u64, state: State, message: Option<String>, ) -> Self
Creates a new progress update.
This method is primarily used internally by the progress tracking system.
Users should use the progress function instead of creating updates manually.
Sourcepub const fn total(&self) -> u64
pub const fn total(&self) -> u64
Returns the total expected value when the operation will be complete.
Sourcepub fn completed_fraction(&self) -> f64
pub fn completed_fraction(&self) -> f64
Returns the completion fraction as a value between 0.0 and 1.0.
If the total is 0, returns 0.0. Otherwise, returns current/total.
Sourcepub const fn remaining(&self) -> u64
pub const fn remaining(&self) -> u64
Returns the remaining progress (total - current).
Uses saturating subtraction, so if current > total, returns 0.
Sourcepub const fn is_cancelled(&self) -> bool
pub const fn is_cancelled(&self) -> bool
Returns true if the state is Cancelled.
Sourcepub const fn is_working(&self) -> bool
pub const fn is_working(&self) -> bool
Returns true if the state is Working.
Sourcepub const fn is_completed(&self) -> bool
pub const fn is_completed(&self) -> bool
Returns true if the state is Completed.
Trait Implementations§
Source§impl Clone for ProgressUpdate
impl Clone for ProgressUpdate
Source§fn clone(&self) -> ProgressUpdate
fn clone(&self) -> ProgressUpdate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more