Skip to main content

ChildChoice

Enum ChildChoice 

Source
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§

Source§

impl<Head, Tail, Position, Child> ChildPosition<ChildChoice<Head, Tail>, Child> for ChildTail<Position>
where Child: Behavior, Position: ChildPosition<Tail, Child>,

Source§

impl<Head: Behavior, Tail> ChildPosition<ChildChoice<Head, Tail>, Head> for ChildHead

Source§

impl<Head: Clone, Tail: Clone> Clone for ChildChoice<Head, Tail>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<Head: Debug, Tail: Debug> Debug for ChildChoice<Head, Tail>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A, Head, Tail, Installer, Output, Error> DispatchBirth<A, Installer, Output, Error> for ChildChoice<Head, Tail>
where A: Address, A::Nonce: Send, Head: Behavior + Send, Head::Protocol: Protocol<Addr = A>, Tail: DispatchBirth<A, Installer, Output, Error> + Send, Installer: InstallBirth<A, Head, Output, Error> + Send,

Source§

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
Source§

impl<Head: Eq, Tail: Eq> Eq for ChildChoice<Head, Tail>

Source§

impl<Head: PartialEq, Tail: PartialEq> PartialEq for ChildChoice<Head, Tail>

Source§

fn eq(&self, other: &ChildChoice<Head, Tail>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<Head: PartialEq, Tail: PartialEq> StructuralPartialEq for ChildChoice<Head, Tail>

Auto Trait Implementations§

§

impl<Head, Tail> Freeze for ChildChoice<Head, Tail>
where Head: Freeze, Tail: Freeze,

§

impl<Head, Tail> RefUnwindSafe for ChildChoice<Head, Tail>
where Head: RefUnwindSafe, Tail: RefUnwindSafe,

§

impl<Head, Tail> Send for ChildChoice<Head, Tail>
where Head: Send, Tail: Send,

§

impl<Head, Tail> Sync for ChildChoice<Head, Tail>
where Head: Sync, Tail: Sync,

§

impl<Head, Tail> Unpin for ChildChoice<Head, Tail>
where Head: Unpin, Tail: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.