Skip to main content

ActionItem

Trait ActionItem 

Source
pub trait ActionItem: Sized + Send {
    type Accepted: Send;
    type Rejection: Send;
    type Prerequisite: Send;
    type Custody;
    type Input<'a>
       where Self: 'a;
    type Reply;

    // Required methods
    fn prepare_interpretation(
        progress: &mut Option<InterpretationProgress<Self, Self::Custody, ItemSettlement<Self, Self::Accepted, Self::Rejection, Self::Prerequisite>>>,
    );
    fn interpretation_input<'a>(
        custody: &'a mut Self::Custody,
    ) -> Option<(Self::Input<'a>, &'a mut Option<Self::Reply>)>
       where Self: 'a;
    fn finish_interpretation(
        progress: &mut Option<InterpretationProgress<Self, Self::Custody, ItemSettlement<Self, Self::Accepted, Self::Rejection, Self::Prerequisite>>>,
    );

    // Provided method
    fn retain_accepted(_: Self::Accepted) -> Option<Self::Accepted> { ... }
}
Expand description

One concrete value that can occur in crate::Actions.

The capability item owns its settlement vocabulary. Every conforming interpreter therefore agrees on the exact accepted receipt, rejection, and prerequisite types for that item. Interpreter corruption is the one shared InterpreterFault sum.

A runtime cannot substitute a different rejection type for the same item:

ⓘ
struct Request;
struct RequiredRejection;
struct RuntimeRejection;
impl behavior::ActionItem for Request {
    type Accepted = (); type Rejection = RequiredRejection; type Prerequisite = behavior::Never;
    type Custody = (Option<Self>, Option<Self::Reply>);
    type Input<'a> = &'a mut Option<Self> where Self: 'a;
    type Reply = behavior::ItemSettlement<Self, (), RequiredRejection, behavior::Never>;
    fn prepare_interpretation(progress: &mut Option<behavior::InterpretationProgress<Self, Self::Custody, Self::Reply>>) { behavior::prepare_item::<Self>(progress); }
    fn interpretation_input<'a>(custody: &'a mut Self::Custody) -> Option<(Self::Input<'a>, &'a mut Option<Self::Reply>)> where Self: 'a {
        let (input, received) = custody;
        match (&*input, &*received) { (Some(_), None) => Some((input, received)), _ => None }
    }
    fn finish_interpretation(progress: &mut Option<behavior::InterpretationProgress<Self, Self::Custody, Self::Reply>>) { behavior::finish_item::<Self>(progress); }
}
struct Runtime;
impl behavior::InterpretItem<Request, (), behavior::Here> for Runtime {
    fn interpret_item<'a>(&'a mut self, input: &'a mut Option<Request>, received: &'a mut Option<<Request as behavior::ActionItem>::Reply>) -> impl core::future::Future<Output = ()> + Send + 'a where Request: 'a {
        async move {
            if received.is_some() { return; }
            let Some(item) = input.take() else { return; };
            *received = Some(behavior::ItemSettlement::Rejected { item, reason: RuntimeRejection });
        }
    }
}

Required Associated Types§

Required Methods§

Source

fn prepare_interpretation( progress: &mut Option<InterpretationProgress<Self, Self::Custody, ItemSettlement<Self, Self::Accepted, Self::Rejection, Self::Prerequisite>>>, )

Source

fn interpretation_input<'a>( custody: &'a mut Self::Custody, ) -> Option<(Self::Input<'a>, &'a mut Option<Self::Reply>)>
where Self: 'a,

Source

fn finish_interpretation( progress: &mut Option<InterpretationProgress<Self, Self::Custody, ItemSettlement<Self, Self::Accepted, Self::Rejection, Self::Prerequisite>>>, )

Provided Methods§

Source

fn retain_accepted(_: Self::Accepted) -> Option<Self::Accepted>

Keep an accepted value only while it still carries terminal custody.

The default discharges and destroys the receipt. An implementation returning Some must return the same owned value on every later offer; it must not perform an effect or consume authority still promised by that value. This decision does not change settlement status.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<A, New> ActionItem for Creations<CreateChild<A, New>>
where A: Address, A::Nonce: Send, New: Send,

Source§

impl<Child, Source, Input, Occurrence> ActionItem for ChildInput<Child, Source, Input, Occurrence>
where Child: Behavior, Input: Send,

Source§

type Custody = (Option<ChildInput<Child, Source, Input, Occurrence>>, Option<<ChildInput<Child, Source, Input, Occurrence> as ActionItem>::Reply>)

Source§

type Input<'a> = &'a mut Option<ChildInput<Child, Source, Input, Occurrence>> where Self: 'a

Source§

type Reply = ItemSettlement<ChildInput<Child, Source, Input, Occurrence>, <ChildInput<Child, Source, Input, Occurrence> as ActionItem>::Accepted, <ChildInput<Child, Source, Input, Occurrence> as ActionItem>::Rejection, <ChildInput<Child, Source, Input, Occurrence> as ActionItem>::Prerequisite>

Source§

type Accepted = ()

Source§

type Rejection = ChildInputReason

Source§

type Prerequisite = CreationCorrelation<<Child as Behavior>::Protocol, Occurrence>

Source§

impl<P> ActionItem for Delivery<P>
where P: Protocol, P::Addr: Send, P::Msg: Send,

Source§

impl<P> ActionItem for EstablishedDelivery<P>

Source§

impl<P, Occurrence> ActionItem for ChildDelivery<P, Occurrence>
where P: Protocol, P::Msg: Send,

Source§

type Custody = (Option<ChildDelivery<P, Occurrence>>, Option<<ChildDelivery<P, Occurrence> as ActionItem>::Reply>)

Source§

type Input<'a> = &'a mut Option<ChildDelivery<P, Occurrence>> where Self: 'a

Source§

type Reply = ItemSettlement<ChildDelivery<P, Occurrence>, <ChildDelivery<P, Occurrence> as ActionItem>::Accepted, <ChildDelivery<P, Occurrence> as ActionItem>::Rejection, <ChildDelivery<P, Occurrence> as ActionItem>::Prerequisite>

Source§

type Accepted = ()

Source§

type Rejection = ChildDeliveryReason

Source§

type Prerequisite = CreationCorrelation<P, Occurrence>

Source§

impl<R> ActionItem for ReportToParent<R>
where R: Send,