use crate::{CloseReason, Delivery};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum OperationPhase {
Queued,
Writing,
AwaitingReply,
Terminal,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum OperationFailure {
DeadlineElapsed,
ConnectionClosed(CloseReason),
MatchKeyMismatch {
expected: crate::MatchKey,
received: crate::MatchKey,
},
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum OperationOutcome<F> {
Reply(F),
WriteComplete {
delivery: Delivery,
},
Failed {
failure: OperationFailure,
delivery: Delivery,
},
Cancelled {
delivery: Delivery,
},
}
impl<F: calandria::Retained> calandria::Retained for OperationOutcome<F> {
fn retained_bytes(&self) -> calandria::RetainedBytes {
match self {
Self::Reply(frame) => frame.retained_bytes(),
Self::WriteComplete { .. } | Self::Failed { .. } | Self::Cancelled { .. } => {
calandria::RetainedBytes::ZERO
}
}
}
}