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§
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 Methods§
Sourcefn retain_accepted(_: Self::Accepted) -> Option<Self::Accepted>
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.