//! Outcome enums for the runner entry points — richer, self-describing
//! return types than bare `Option`/`bool`/`()` (review DX-29/DX-8).
//!
//! `SignalOutcome` lands first: `signal` previously returned `Result<()>`,
//! silently swallowing whether a `RoutesToStep` signal actually reached an
//! awaiting step (DX-8/SAGA-10). `TriggerOutcome`/`DeliverOutcome` will follow.

/// The result of delivering a signal to a saga instance.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum SignalOutcome {
    /// The signal was consumed: a `TriggersCompensation` signal cancelled the
    /// instance and ran its compensation, or a `RoutesToStep` signal was
    /// routed to and consumed by the awaiting step.
    Accepted,
    /// A `RoutesToStep` signal arrived **before** its target step had
    /// suspended. It was persisted durably and will be consumed automatically
    /// the moment the step suspends (review SAGA-10). The caller does not need
    /// to retry. At most one unconsumed signal per `(instance, type)` is
    /// allowed; a second is rejected (see the runners' `DuplicateBufferedSignal`).
    Buffered,
}

impl SignalOutcome {
    /// `true` if the signal was consumed by the saga.
    pub fn accepted(self) -> bool {
        matches!(self, SignalOutcome::Accepted)
    }
}
