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
//! Separately bounded connection-lifecycle publications.
use bornera_core::{CloseReason, ConnectionEpoch};
use calandria::{Retained, RetainedBytes};
/// One mechanical lifecycle edge for a fixed connection epoch.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum ConnectionEvent {
/// The transport became ready to exchange application bytes.
///
/// Protocol negotiation and regular operation admission remain caller-owned.
TransportOpened {
/// Monotonic event sequence within this engine.
sequence: u64,
/// Exact established transport lifetime.
epoch: ConnectionEpoch,
},
/// The protocol session owner opened regular operation admission.
AdmissionOpened {
/// Monotonic event sequence within this engine.
sequence: u64,
/// Exact session-bearing transport lifetime.
epoch: ConnectionEpoch,
},
/// Core policy began terminal closure.
Closing {
/// Monotonic event sequence within this engine.
sequence: u64,
/// Exact closing transport lifetime.
epoch: ConnectionEpoch,
/// Mechanical reason retained by the fixed epoch.
reason: CloseReason,
},
/// The private transport capability completed closure.
Closed {
/// Monotonic event sequence within this engine.
sequence: u64,
/// Exact closed transport lifetime.
epoch: ConnectionEpoch,
/// Mechanical reason retained by the fixed epoch.
reason: CloseReason,
},
}
impl ConnectionEvent {
/// Returns the monotonic sequence assigned at publication.
pub const fn sequence(self) -> u64 {
match self {
Self::TransportOpened { sequence, .. }
| Self::AdmissionOpened { sequence, .. }
| Self::Closing { sequence, .. }
| Self::Closed { sequence, .. } => sequence,
}
}
/// Returns the exact transport lifetime that produced the edge.
pub const fn epoch(self) -> ConnectionEpoch {
match self {
Self::TransportOpened { epoch, .. }
| Self::AdmissionOpened { epoch, .. }
| Self::Closing { epoch, .. }
| Self::Closed { epoch, .. } => epoch,
}
}
}
impl Retained for ConnectionEvent {
fn retained_bytes(&self) -> RetainedBytes {
RetainedBytes::ZERO
}
}