1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! A progress event.
use std::borrow::Cow;
use crate::{PriorityLevel, ProgressId};
/// A progress event.
#[derive(Clone, Eq, PartialEq, Debug)]
pub enum Event {
/// A progress had its task updated.
Update(UpdateEvent),
/// A progress has posted a message.
Message(MessageEvent),
/// A progress has been removed.
Detachment(DetachmentEvent),
/// The generation counter has overflowed.
///
/// This event is emitted when the internal generation counter wraps around after
/// reaching [`usize::MAX`]. Generation counters are used to track changes to progress
/// tasks and enable efficient delta reporting via [`Reporter::partial_report`].
///
/// # When This Occurs
///
/// Generation overflow is extremely rare in practice, requiring billions of task updates
/// (2^64 on 64-bit systems, 2^32 on 32-bit systems). In typical applications, this event
/// will never occur during normal operation.
///
/// # What To Do
///
/// When this event is received, observers should:
///
/// - Log the occurrence for monitoring purposes
/// - Continue normal operation - the generation counter wraps safely
/// - Be aware that generation-based comparisons may temporarily be incorrect immediately
/// after overflow, but will self-correct as new updates occur
///
/// No action is typically required as the system continues to function correctly after
/// overflow. The wrapping behavior is intentional and safe.
///
/// [`Reporter::partial_report`]: crate::Reporter::partial_report
GenerationOverflow,
}
/// A update event.
#[derive(Clone, Eq, PartialEq, Debug)]
pub struct UpdateEvent {
/// The associated progress' identifier.
pub id: ProgressId,
}
/// A message event.
#[derive(Clone, Eq, PartialEq, Debug)]
pub struct MessageEvent {
/// The associated progress' identifier.
pub id: ProgressId,
/// The posted message.
pub message: Cow<'static, str>,
/// The message's priority level.
pub priority: PriorityLevel,
}
/// A detachment event.
#[derive(Clone, Eq, PartialEq, Debug)]
pub struct DetachmentEvent {
/// The associated progress' identifier.
pub id: ProgressId,
}