bornera_core/connection/
transition.rs1use crate::ConnectionEffect;
4
5#[derive(Clone, Copy, Debug, Eq, PartialEq)]
7#[non_exhaustive]
8pub enum InputDisposition {
9 Applied,
11 IgnoredStaleEpoch,
13 IgnoredUnknownOperation,
15 IgnoredStaleEffect,
17 AlreadyTerminal,
19 IgnoredInvalidPhase,
21 Fault,
23}
24
25#[derive(Clone, Copy, Debug, Eq, PartialEq)]
27#[non_exhaustive]
28pub enum CancelOutcome {
29 CancelledNotSent,
31 ObservationCancelled {
33 delivery: crate::Delivery,
35 },
36 AlreadyTerminal,
38}
39
40#[must_use = "connection transitions contain required deadline, closure, and publication effects"]
42#[derive(Clone, Debug, Eq, PartialEq)]
43pub struct ConnectionTransition<F = ()> {
44 disposition: InputDisposition,
45 cancel_outcome: Option<CancelOutcome>,
46 effects: Vec<ConnectionEffect<F>>,
47}
48
49impl<F> ConnectionTransition<F> {
50 pub(crate) fn new(disposition: InputDisposition) -> Self {
51 Self {
52 disposition,
53 cancel_outcome: None,
54 effects: Vec::new(),
55 }
56 }
57
58 pub(crate) fn cancelled(mut self, outcome: CancelOutcome) -> Self {
59 self.cancel_outcome = Some(outcome);
60 self
61 }
62
63 pub(crate) fn push(&mut self, effect: ConnectionEffect<F>) {
64 self.effects.push(effect);
65 }
66
67 pub const fn disposition(&self) -> InputDisposition {
69 self.disposition
70 }
71
72 pub const fn cancel_outcome(&self) -> Option<CancelOutcome> {
74 self.cancel_outcome
75 }
76
77 pub fn effects(&self) -> &[ConnectionEffect<F>] {
79 &self.effects
80 }
81
82 pub fn into_effects(self) -> Vec<ConnectionEffect<F>> {
84 self.effects
85 }
86}