1use tokio::time::Instant;
8
9use crate::behavior::Address;
10use crate::{Crash, Exit};
11
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
13pub struct AtId(pub u64);
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
16pub struct AtGeneration(pub u64);
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq)]
19pub struct ScheduleAt {
20 pub id: AtId,
21 pub generation: AtGeneration,
22 pub at: Instant,
23}
24
25#[derive(Debug, Clone, Copy, PartialEq, Eq)]
26pub struct TimeReached {
27 pub id: AtId,
28 pub generation: AtGeneration,
29 pub at: Instant,
30}
31
32pub trait TimeEvent: Sized {
33 fn time_reached(event: TimeReached) -> Option<Self>;
34}
35
36#[derive(Debug, Clone, Copy, PartialEq, Eq)]
37pub struct ObservePeer<A> {
38 pub peer: A,
39}
40
41#[derive(Debug, Clone, PartialEq, Eq)]
42pub struct PeerStopped<A: Address> {
43 pub peer: A,
44 pub outcome: Result<Exit<A>, Crash>,
45}
46
47pub trait PeerEvent<A: Address>: Sized {
48 fn peer_stopped(event: PeerStopped<A>) -> Option<Self>;
49}
50
51#[derive(Debug, Clone, PartialEq, Eq)]
52pub struct ChildStopped<A: Address> {
53 pub nonce: A::Nonce,
54 pub outcome: Result<Exit<A>, Crash>,
55 pub at: Instant,
56}
57
58#[derive(Debug, Clone, Copy, PartialEq, Eq)]
59pub struct ObserveChild<A: Address> {
60 pub nonce: A::Nonce,
61}
62
63#[derive(Debug, Clone, PartialEq, Eq)]
67pub struct ReportWorkerStopped<A: Address> {
68 pub outcome: Result<Exit<A>, Crash>,
69 pub at: Instant,
70}
71
72#[derive(Debug, Clone, PartialEq, Eq)]
74pub struct WorkerStopped<A: Address> {
75 pub proxy: A::Nonce,
76 pub outcome: Result<Exit<A>, Crash>,
77 pub at: Instant,
78}
79
80pub trait ChildEvent<A: Address>: Sized {
81 fn child_stopped(event: ChildStopped<A>) -> Option<Self>;
82}
83
84pub trait WorkerEvent<A: Address>: Sized {
85 fn worker_stopped(event: WorkerStopped<A>) -> Option<Self>;
86}
87
88#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
90pub struct ShutdownRequested;
91
92pub trait ShutdownEvent: Sized {
93 fn shutdown_requested(event: ShutdownRequested) -> Option<Self>;
94}