Skip to main content

Carrier

Derive Macro Carrier 

Source
#[derive(Carrier)]
{
    // Attributes available to this derive:
    #[carrier]
}
Expand description

Derive a carrier: a crate-local lane enum that stands in for Fault<lanes!(..)> or Fail<R, lanes!(..)>.

ⓘ
#[derive(Debug, errlanes::Carrier)]
#[carrier(from(effects::HostFault))]
pub enum PartyFault {
    /// the subject may not do this
    Denied(errlanes::Denied),
    Transient(errlanes::Transient),
    Fatal(errlanes::Fatal),
}

#[derive(Debug, errlanes::Carrier)]
pub enum WriteError<R> {
    Rejected(R),
    Transient(errlanes::Transient),
    Fatal(errlanes::Fatal),
}

The variant names are the profile: each is a one-field tuple variant named from Rejected / Denied / Transient / Fatal, at most one of each. Rejected(T) makes the carrier Fail-like with rejection T (a concrete type or one of the enum’s own generic parameters); without it the carrier is Fault-like and needs at least one lane. #[carrier(from(Up, ..))] lists other carriers that convert into this one by ?. Debug is yours to derive (Error needs it).