Skip to main content

made_core/ports/
host_activation_outcome.rs

1use crate::value_objects::{DeliveryFailureReason, HostActivationReceipt};
2
3/// What an activation adapter did with an envelope.
4///
5/// `Unsupported` is a first-class answer rather than an error: a
6/// deployment with no adapter is a normal deployment, and its hosts
7/// find their work by asking for it. Telling that apart from a wake-up
8/// that failed is what lets an operator know whether to go looking.
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub enum HostActivationOutcome {
11    /// The host was reached. Transport, not processing.
12    Accepted(HostActivationReceipt),
13    /// This deployment does not wake hosts.
14    Unsupported,
15    /// The adapter tried and could not.
16    Failed(DeliveryFailureReason),
17}
18
19impl HostActivationOutcome {
20    #[must_use]
21    pub const fn receipt(&self) -> Option<&HostActivationReceipt> {
22        match self {
23            Self::Accepted(receipt) => Some(receipt),
24            Self::Unsupported | Self::Failed(_) => None,
25        }
26    }
27
28    #[must_use]
29    pub const fn is_accepted(&self) -> bool {
30        matches!(self, Self::Accepted(_))
31    }
32}