#[derive(OutcomeLattice)]
{
// Attributes available to this derive:
#[outcome_lattice]
#[outcome]
}
Expand description
#[derive(OutcomeLattice)] — auto-implement an OutcomeLattice
trait from per-variant severity attributes.
Expected trait shape:
ⓘ
pub trait OutcomeLattice: Clone + PartialEq {
fn severity(&self) -> u32;
fn baseline() -> Self;
fn worst(&self, other: &Self) -> Self { ... }
fn best(&self, other: &Self) -> Self { ... }
}The derive emits severity() (from per-variant attrs) +
baseline() (returning the single #[outcome(baseline)]-tagged
unit variant). worst + best come from the trait’s defaults.
§Attributes
#[outcome_lattice(trait_path = "::path::to::OutcomeLattice")]— fully-qualified trait path (default unqualifiedOutcomeLattice— consumer mustuse the_trait::OutcomeLatticein scope).- Per-variant
#[outcome(severity = N)]— severity for this variant (u32; default 0 if unspecified). - Per-variant
#[outcome(baseline)]— marks the unit variant thatbaseline()returns. Exactly ONE variant must carry this; it must be a unit variant.
§Example
ⓘ
use magma_converge::outcome::OutcomeLattice;
#[derive(Clone, PartialEq, gen_platform::OutcomeLattice)]
enum ReadyState {
#[outcome(severity = 0, baseline)]
Ready,
#[outcome(severity = 1)]
Unknown,
#[outcome(severity = 2)]
InProgress { reason: String },
#[outcome(severity = 3)]
Failed { reason: String },
}
// Auto-generated:
// impl OutcomeLattice for ReadyState {
// fn severity(&self) -> u32 { match self { ... } }
// fn baseline() -> Self { Self::Ready }
// }