pub struct Progress {
pub current: usize,
pub total: usize,
pub status: Option<String>,
}Expand description
Progress information for long-running operations.
This struct tracks the current progress of operations like file uploads, downloads, or dataset processing. It provides the current count, total count, and an optional status string to enable progress reporting in applications.
§Multi-Stage Progress
The status field enables multi-stage progress tracking. When an operation
has multiple phases, the status field changes to indicate the current phase.
Applications should detect status changes to reset their progress display.
§Operation Progress Details
| Operation | Status | Unit | Notes |
|---|---|---|---|
download_dataset | None then "Downloading" | samples | Two phases: fetch metadata, then download files |
populate_samples | None | samples | Each sample may contain multiple files |
samples | None | samples | Paginated API fetch |
sample_names | None | samples | Paginated API fetch, names only |
annotations | None | samples | Samples processed for annotations |
download_artifact | None | bytes | Single file byte-level progress |
download_checkpoint | None | bytes | Single file byte-level progress |
download_snapshot | None | bytes | Combined byte progress across all files |
§Examples
Basic progress display:
use edgefirst_client::Progress;
let progress = Progress {
current: 25,
total: 100,
status: Some("Downloading".to_string()),
};
let percentage = (progress.current as f64 / progress.total as f64) * 100.0;
println!(
"{}: {:.1}% ({}/{})",
progress.status.as_deref().unwrap_or("Progress"),
percentage,
progress.current,
progress.total
);Multi-stage progress handling (e.g., for download_dataset):
let mut last_status: Option<String> = None;
while let Some(progress) = rx.recv().await {
// Detect stage change and reset progress bar
if progress.status != last_status {
if let Some(ref status) = progress.status {
println!("\n{}", status);
}
last_status = progress.status.clone();
}
let pct = (progress.current as f64 / progress.total as f64) * 100.0;
print!("\r{:.1}% ({}/{})", pct, progress.current, progress.total);
}Fields§
§current: usizeCurrent number of completed items or bytes.
total: usizeTotal number of items or bytes to process.
status: Option<String>Optional status describing the current operation phase.
When this value changes from None to Some(...) or between different
values, it indicates a new phase has started. Applications should reset
their progress display when the status changes.
Currently only Client::download_dataset uses status changes:
- Phase 1:
Nonewhile fetching sample metadata - Phase 2:
"Downloading"while downloading files
All other operations use None throughout.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Progress
impl RefUnwindSafe for Progress
impl Send for Progress
impl Sync for Progress
impl Unpin for Progress
impl UnsafeUnpin for Progress
impl UnwindSafe for Progress
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more