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
//! Fixed-size commands fenced to one exact connection-set generation.
use bornera_core::{OperationId, RetainedBytes};
use calandria::{Deadline, Retained};
use crate::ConnectionToken;
/// One mechanical command queued for an exact live connection generation.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum ConnectionCommand {
/// Opens regular admission after protocol-owned session establishment.
OpenAdmission {
/// Exact set generation authorized by the sender.
connection: ConnectionToken,
},
/// Explicitly cancels local observation of one accepted operation.
Cancel {
/// Exact set generation authorized by the sender.
connection: ConnectionToken,
/// Operation to cancel.
operation: OperationId,
},
/// Closes admission before draining accepted work.
BeginDrain {
/// Exact set generation authorized by the sender.
connection: ConnectionToken,
/// Absolute bound for draining plus transport-local graceful shutdown.
deadline: Deadline,
},
/// Forces requested closure of one exact connection lifetime.
Close {
/// Exact set generation authorized by the sender.
connection: ConnectionToken,
},
}
impl ConnectionCommand {
pub(crate) const fn connection(self) -> ConnectionToken {
match self {
Self::OpenAdmission { connection }
| Self::Cancel { connection, .. }
| Self::BeginDrain { connection, .. }
| Self::Close { connection } => connection,
}
}
}
impl Retained for ConnectionCommand {
fn retained_bytes(&self) -> RetainedBytes {
RetainedBytes::ZERO
}
}