Skip to main content

made_core/ports/
recorded_activation.rs

1use crate::value_objects::HostDeliveryRecord;
2
3/// What writing down an activation did to a delivery.
4///
5/// An activation is a push, so the answers are not the leased ones.
6/// Reaching a host is transport and nothing more: a delivered record
7/// stays offerable, and the host still has to come and take the work
8/// under its own lease. What an operator needs to tell apart afterwards
9/// is a deployment that does not wake hosts from one that tried and
10/// could not, which is why `NotAttempted` is an answer rather than a
11/// silence.
12#[derive(Debug, Clone, PartialEq, Eq)]
13pub enum RecordedActivation {
14    /// The host was reached, and the receipt says how.
15    Delivered(HostDeliveryRecord),
16    /// This deployment does not wake hosts; nothing was written.
17    NotAttempted(HostDeliveryRecord),
18    /// The wake-up failed and the delivery has attempts left.
19    Requeued(HostDeliveryRecord),
20    /// The wake-up failed and the delivery ran out of attempts.
21    Exhausted(HostDeliveryRecord),
22    /// The delivery already ended; an activation does not reopen it.
23    AlreadyEnded(HostDeliveryRecord),
24    /// No delivery of that identity is held.
25    Unknown,
26}
27
28impl RecordedActivation {
29    #[must_use]
30    pub const fn record(&self) -> Option<&HostDeliveryRecord> {
31        match self {
32            Self::Delivered(record)
33            | Self::NotAttempted(record)
34            | Self::Requeued(record)
35            | Self::Exhausted(record)
36            | Self::AlreadyEnded(record) => Some(record),
37            Self::Unknown => None,
38        }
39    }
40
41    /// Whether the host is known to have been reached.
42    #[must_use]
43    pub const fn reached_the_host(&self) -> bool {
44        matches!(self, Self::Delivered(_))
45    }
46}