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
76
77
78
79
80
81
82
83
84
//! Data-only inputs accepted by one connection epoch.
use calandria::Moment;
use crate::{CloseReason, ConnectionEpoch, OperationId};
/// An observation or command applied to the deterministic epoch machine.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum ConnectionInput {
/// The protocol session owner completed establishment.
OpenAdmission {
/// Exact epoch whose protocol session was established.
epoch: ConnectionEpoch,
},
/// Explicitly cancel local operation ownership.
Cancel {
/// Epoch named by the caller.
epoch: ConnectionEpoch,
/// Operation to cancel.
operation: OperationId,
},
/// A scheduled absolute deadline was observed.
DeadlineElapsed {
/// Epoch named by the timer event.
epoch: ConnectionEpoch,
/// Operation whose deadline was scheduled.
operation: OperationId,
/// Current fixed-width monotonic moment.
now: Moment,
},
/// The adapter rejected a complete inbound frame as malformed.
ReplyMalformed {
/// Epoch that produced the malformed frame.
epoch: ConnectionEpoch,
},
/// Close admission, then finish already accepted work.
BeginDrain {
/// Exact epoch whose admission should close before draining.
epoch: ConnectionEpoch,
},
/// Force closure of this epoch.
CloseRequested {
/// Epoch named by the requester or capability.
epoch: ConnectionEpoch,
/// Mechanical closure reason.
reason: CloseReason,
},
/// Confirm that the physical capability is closed.
EpochClosed {
/// Epoch whose capability closed.
epoch: ConnectionEpoch,
},
}
/// A complete opaque frame classified by an adapter as a reply.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct InboundReply<F> {
pub(crate) epoch: ConnectionEpoch,
pub(crate) key: crate::MatchKey,
pub(crate) frame: F,
}
impl<F> InboundReply<F> {
/// Creates a reply input after protocol-specific classification.
pub const fn new(epoch: ConnectionEpoch, key: crate::MatchKey, frame: F) -> Self {
Self { epoch, key, frame }
}
/// Returns the epoch that produced the frame.
pub const fn epoch(&self) -> ConnectionEpoch {
self.epoch
}
/// Returns the protocol-visible match key extracted by the adapter.
pub const fn key(&self) -> crate::MatchKey {
self.key
}
/// Recovers the opaque frame before it is applied to a machine.
pub fn into_frame(self) -> F {
self.frame
}
}