pub enum ChildChoice<Head, Tail> {
Head(Head),
Tail(Tail),
}Expand description
One alternative in a closed, recursively composed child-creation sum.
Head is one concrete child behavior and Tail is the remaining closed
sum. This is a creation choice only: it is not a behavior, message
envelope, registry, or runtime dispatch mechanism.
Every alternative requires a concrete installer; incomplete interpreter support is rejected statically:
ⓘ
use behavior::{
Actions, Behavior, BehaviorActed, ChildChoice, Create, DispatchBirth,
InstallBirth, MailAddr, Never, NoBirths, Protocol, User,
};
struct First;
struct Second;
macro_rules! inert {
($child:ty) => {
impl Protocol for $child {
type Addr = MailAddr;
type Msg = Never;
}
impl Behavior for $child {
type Event = User<MailAddr, Never>;
type Sends = Vec<Never>;
type Ph = Never;
type Error = Never;
type Birth = NoBirths;
fn transition(
&mut self,
_: behavior::ActiveTurn,
event: Self::Event,
) -> BehaviorActed<Self> {
match event.message {}
}
}
};
}
inert!(First);
inert!(Second);
struct Incomplete;
impl InstallBirth<MailAddr, First, (), Never> for Incomplete {
async fn install_birth(
&mut self,
_: Create<MailAddr, First>,
) -> Result<(), Never> {
Ok(())
}
}
type Both = ChildChoice<First, ChildChoice<Second, Never>>;
fn require_complete<T: DispatchBirth<MailAddr, Incomplete, (), Never>>() {}
require_complete::<Both>();Variants§
Head(Head)
Select the concrete child at this position.
Tail(Tail)
Select one concrete child from the remaining alternatives.
Trait Implementations§
impl<Head, Tail, Position, Child> ChildPosition<ChildChoice<Head, Tail>, Child> for ChildTail<Position>where
Child: Behavior,
Position: ChildPosition<Tail, Child>,
impl<Head: Behavior, Tail> ChildPosition<ChildChoice<Head, Tail>, Head> for ChildHead
Source§impl<Head: Clone, Tail: Clone> Clone for ChildChoice<Head, Tail>
impl<Head: Clone, Tail: Clone> Clone for ChildChoice<Head, Tail>
Source§fn clone(&self) -> ChildChoice<Head, Tail>
fn clone(&self) -> ChildChoice<Head, Tail>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<A, Head, Tail, Installer, Output, Error> DispatchBirth<A, Installer, Output, Error> for ChildChoice<Head, Tail>
impl<A, Head, Tail, Installer, Output, Error> DispatchBirth<A, Installer, Output, Error> for ChildChoice<Head, Tail>
Source§async fn dispatch_birth(
self,
nonce: A::Nonce,
kind: CreationKind<A::Nonce>,
installer: &mut Installer,
) -> Result<Output, Error>
async fn dispatch_birth( self, nonce: A::Nonce, kind: CreationKind<A::Nonce>, installer: &mut Installer, ) -> Result<Output, Error>
Select exactly one concrete installer while preserving creation data. Read more
impl<Head: Eq, Tail: Eq> Eq for ChildChoice<Head, Tail>
impl<Head: PartialEq, Tail: PartialEq> StructuralPartialEq for ChildChoice<Head, Tail>
Auto Trait Implementations§
impl<Head, Tail> Freeze for ChildChoice<Head, Tail>
impl<Head, Tail> RefUnwindSafe for ChildChoice<Head, Tail>where
Head: RefUnwindSafe,
Tail: RefUnwindSafe,
impl<Head, Tail> Send for ChildChoice<Head, Tail>
impl<Head, Tail> Sync for ChildChoice<Head, Tail>
impl<Head, Tail> Unpin for ChildChoice<Head, Tail>
impl<Head, Tail> UnsafeUnpin for ChildChoice<Head, Tail>where
Head: UnsafeUnpin,
Tail: UnsafeUnpin,
impl<Head, Tail> UnwindSafe for ChildChoice<Head, Tail>where
Head: UnwindSafe,
Tail: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more