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
68
69
70
71
72
73
74
75
use std::convert::Infallible;
use std::time::Duration;
use agner_actors::{ActorID, Event, Exit};
use tokio::sync::oneshot;
pub type Tx<T> = oneshot::Sender<T>;
#[derive(Debug)]
pub enum Query<M> {
Exit(ExitRq),
InitAck(InitAckRq),
SetLink(SetLinkRq),
SetTrapExit(SetTrapExitRq),
NextEvent(NextEventRq<M>),
}
#[derive(Debug)]
pub struct InitAckRq {
pub value: Option<ActorID>,
pub reply_on_drop: Tx<Infallible>,
}
#[derive(Debug)]
pub struct SetLinkRq {
pub actor: ActorID,
pub link: bool,
pub reply_on_drop: Tx<Infallible>,
}
#[derive(Debug)]
pub struct ExitRq {
pub reason: Exit,
pub reply_on_drop: Tx<Infallible>,
}
#[derive(Debug)]
pub struct SetTrapExitRq {
pub set_to: bool,
pub reply_on_drop: Tx<Infallible>,
}
#[derive(Debug)]
pub struct NextEventRq<M> {
pub timeout: Duration,
pub reply_to: Tx<Event<M>>,
}
impl<M> From<InitAckRq> for Query<M> {
fn from(inner: InitAckRq) -> Self {
Self::InitAck(inner)
}
}
impl<M> From<SetLinkRq> for Query<M> {
fn from(inner: SetLinkRq) -> Self {
Self::SetLink(inner)
}
}
impl<M> From<ExitRq> for Query<M> {
fn from(inner: ExitRq) -> Self {
Self::Exit(inner)
}
}
impl<M> From<NextEventRq<M>> for Query<M> {
fn from(inner: NextEventRq<M>) -> Self {
Self::NextEvent(inner)
}
}
impl<M> From<SetTrapExitRq> for Query<M> {
fn from(inner: SetTrapExitRq) -> Self {
Self::SetTrapExit(inner)
}
}