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
use async_trait::async_trait;
use std::time::Duration;
#[derive(Clone, Copy)]
pub enum Need {
Restart,
RescheduleAfter(Duration),
Abort,
}
#[async_trait]
pub trait AknShutdown<A>: Send {
async fn aknowledge_shutdown(self, state: A, status: Result<(), Need>);
}
pub trait Shutdown: Send {
fn shutdown(self) -> Option<Self>
where
Self: Sized;
}
pub struct NullSupervisor;
impl NullSupervisor {
pub fn new() -> Option<Self> {
Some(Self)
}
}
#[async_trait]
impl<A: Send + 'static> AknShutdown<A> for NullSupervisor {
async fn aknowledge_shutdown(self, _state: A, _status: Result<(), Need>) {}
}