Skip to main content

made_core/ports/
delivery_failure_outcome.rs

1use crate::value_objects::HostDeliveryRecord;
2
3/// What a failed attempt did to a delivery.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum DeliveryFailureOutcome {
6    /// Attempts remain; it is back in the queue.
7    Requeued(HostDeliveryRecord),
8    /// Attempts ran out; the failure is visible and stays.
9    Exhausted(HostDeliveryRecord),
10    /// The lease offered is not the one that holds this delivery.
11    LeaseNotOwned,
12}
13
14impl DeliveryFailureOutcome {
15    #[must_use]
16    pub const fn record(&self) -> Option<&HostDeliveryRecord> {
17        match self {
18            Self::Requeued(record) | Self::Exhausted(record) => Some(record),
19            Self::LeaseNotOwned => None,
20        }
21    }
22
23    #[must_use]
24    pub const fn is_exhausted(&self) -> bool {
25        matches!(self, Self::Exhausted(_))
26    }
27}