#[non_exhaustive]pub enum ProgressEvent<'a> {
Message(&'a str),
Started {
total: u64,
},
Advanced {
done: u64,
total: u64,
item: Option<&'a str>,
},
Finished {
done: u64,
total: u64,
},
}Expand description
An event on the long-running-work progress stream.
Covers free-form status chatter emitted while long work advances
(ProgressEvent::Message: worker-pool drain notices, per-batch
translation progress, retry notices) and the structured unit-counted
stream (Started / Advanced / Finished) opened by loops that know
their work in advance.
§Stream contract
A structured stream is exactly one ProgressEvent::Started, zero or
more ProgressEvent::Advanced, and exactly one
ProgressEvent::Finished. Advanced.done is non-decreasing and never
exceeds total; a Finished with done < total means the stream
stopped early (cancellation or a first-error abort). A reporter keeps at
most one open stream at a time: a second Started replaces the
current stream rather than nesting a second one.
The enum stays #[non_exhaustive] so future variants remain a
minor-version event; every consumer match therefore needs a wildcard
arm.
§Examples
use subx_core::core::report::ProgressEvent;
let stream = [
ProgressEvent::Started { total: 2 },
ProgressEvent::Advanced { done: 1, total: 2, item: Some("movie.srt") },
ProgressEvent::Finished { done: 2, total: 2 },
];
match &stream[1] {
ProgressEvent::Advanced { done, total, item } => {
assert_eq!((*done, *total), (1, 2));
assert_eq!(*item, Some("movie.srt"));
}
_ => unreachable!("second event is an Advanced"),
}
// A cancelled or first-error-aborted stream closes with done < total:
match (ProgressEvent::Finished { done: 1, total: 2 }) {
ProgressEvent::Finished { done, total } => assert!(done < total),
_ => {}
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Message(&'a str)
Free-form status line emitted while long-running work advances.
Started
A unit-counted stream is opening; total is the number of units.
total: 0 is a real stream, not an absence of one: the batch was
empty, and a renderer still gets an open-and-close signal.
Advanced
done of total units are complete.
§Arguments
item- Name of the unit that just completed, when the emitter has one to hand out (the audit loop names the subtitle file; a completion counter with no natural per-unit name passesNone).
Fields
Finished
The stream is closing; done < total means it stopped early.
Stopping early is a normal close, not a failure: cancellation and first-error aborts both end their streams this way. A failure of the operation itself is carried by the return value, never by a progress event.
Trait Implementations§
Source§impl<'a> Clone for ProgressEvent<'a>
impl<'a> Clone for ProgressEvent<'a>
Source§fn clone(&self) -> ProgressEvent<'a>
fn clone(&self) -> ProgressEvent<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for ProgressEvent<'a>
impl<'a> Debug for ProgressEvent<'a>
impl<'a> Eq for ProgressEvent<'a>
Source§impl<'a> PartialEq for ProgressEvent<'a>
impl<'a> PartialEq for ProgressEvent<'a>
impl<'a> StructuralPartialEq for ProgressEvent<'a>
Auto Trait Implementations§
impl<'a> Freeze for ProgressEvent<'a>
impl<'a> RefUnwindSafe for ProgressEvent<'a>
impl<'a> Send for ProgressEvent<'a>
impl<'a> Sync for ProgressEvent<'a>
impl<'a> Unpin for ProgressEvent<'a>
impl<'a> UnsafeUnpin for ProgressEvent<'a>
impl<'a> UnwindSafe for ProgressEvent<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.