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 child host; incomplete interpreter support is rejected statically:

ⓘ
#[derive(Clone, Copy, Eq, PartialEq)]
struct RuntimeAddr;
impl behavior::Address for RuntimeAddr { type Nonce = u8; }
#[derive(Clone)]
struct Endpoint;
struct Installed<B: behavior::Behavior>(Endpoint, std::sync::mpsc::Sender<B::Event>);
impl<B: behavior::Behavior> Clone for Installed<B> {
    fn clone(&self) -> Self { Self(self.0.clone(), self.1.clone()) }
}
impl behavior::EndpointAddress for RuntimeAddr {
    type Established<P> = Endpoint where P: behavior::Protocol<Addr = Self>;
    type Installed<B> = Installed<B>
        where B: behavior::Behavior<Protocol: behavior::Protocol<Addr = Self>>;
    fn recipient<B>(installed: &Self::Installed<B>) -> Endpoint
    where B: behavior::Behavior<Protocol: behavior::Protocol<Addr = Self>> {
        installed.0.clone()
    }
}
struct CacheWorker;
struct QueueWorker;

macro_rules! inert {
    ($child:ty) => {
        impl behavior::Protocol for $child {
            type Addr = RuntimeAddr;
            type Msg = behavior::Never;
        }
        impl behavior::Behavior for $child {
            type Protocol = Self;
            type Event = behavior::User<RuntimeAddr, behavior::Never>;
            type Sends = behavior::NoSends;
            type Ph = behavior::Never;
            type Error = behavior::Never;
            type Birth = behavior::NoBirths;

            fn transition(
                &mut self,
                _: behavior::ActiveTurn,
                event: Self::Event,
            ) -> behavior::BehaviorActed<Self> {
                match event.message {}
            }
        }
    };
}
inert!(CacheWorker);
inert!(QueueWorker);

struct Incomplete;
impl behavior::EstablishChild<behavior::ChildHead, CacheWorker> for Incomplete {
    fn establish_child(
        &mut self,
        creation: behavior::RoutedCreation<RuntimeAddr, CacheWorker>,
    ) -> impl core::future::Future<Output = behavior::ItemSettlement<
        behavior::RoutedCreation<RuntimeAddr, CacheWorker>,
        behavior::ChildCreationOutcome<CacheWorker, behavior::ChildHead>,
        behavior::CreationRejection,
        behavior::Never,
    >> + Send {
        async move { behavior::ItemSettlement::Rejected {
            item: creation,
            reason: behavior::CreationRejection::EnvironmentFailed,
        } }
    }
}

type WorkerChoices = behavior::ChildChoice<
    CacheWorker,
    behavior::ChildChoice<QueueWorker, behavior::Never>,
>;
fn require_complete<T: behavior::DispatchBirth<RuntimeAddr, Incomplete>>() {}
require_complete::<WorkerChoices>();

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, Rest, Tail> BirthNodeAppend<Tail> for ChildChoice<Head, Rest>
where Head: Behavior, Rest: BirthNode + BirthNodeAppend<Tail>, Tail: NonEmptyBirthNode, Rest::Output: BirthNode,

Source§

type Output = ChildChoice<Head, <Rest as BirthNodeAppend<Tail>>::Output>

Closed child algebra containing the complete prefix followed by the complete appended tail.
Source§

fn append_prefix(self) -> Self::Output

Inject one child from the existing prefix without changing its structural occurrence.
Source§

fn append_tail(tail: Tail) -> Self::Output

Inject one child from the appended tail after every prefix occurrence.
Source§

fn append_creations<A: Address>( prefix: Creations<CreateChild<A, Self>>, tail: Creations<CreateChild<A, Tail>>, ) -> Creations<CreateChild<A, Self::Output>>

Preserve and concatenate two ordered creation batches.
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 · 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<Head: PartialEq, Tail: PartialEq> PartialEq for ChildChoice<Head, Tail>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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: Eq, Tail: Eq> Eq for ChildChoice<Head, Tail>

Source§

impl<Head, Tail> 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<Node> BirthNodeAppend<Never> for Node
where Node: NonEmptyBirthNode,

Source§

type Output = Node

Closed child algebra containing the complete prefix followed by the complete appended tail.
Source§

fn append_prefix(self) -> <Node as BirthNodeAppend<Never>>::Output

Inject one child from the existing prefix without changing its structural occurrence.
Source§

fn append_tail(tail: Never) -> <Node as BirthNodeAppend<Never>>::Output

Inject one child from the appended tail after every prefix occurrence.
Source§

fn append_creations<A: Address>( prefix: Creations<CreateChild<A, Self>>, tail: Creations<CreateChild<A, Tail>>, ) -> Creations<CreateChild<A, Self::Output>>

Preserve and concatenate two ordered creation batches.
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<Node, Shape> ChildOccurrenceProduct<Shape> for Node
where Node: ChildOccurrenceProductAt<ChildHead, Shape>, Shape: ChildOccurrenceShape,

Source§

type Product = <Node as ChildOccurrenceProductAt<ChildHead, Shape>>::Product

Complete shape-owned representation of this closed birth node.
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<A, Child, Host> DispatchBirth<A, Host> for Child
where A: Address, Child: CreateSelectedChild<A, ChildHead, Host>,

Source§

fn dispatch_birth( self, id: CreationId, route: <A as Address>::Nonce, kind: CreationKind, host: &mut Host, ) -> impl Future<Output = ItemSettlement<RoutedCreation<A, Child>, <Child as ChildCreationProduct<A, ChildHead>>::Result, CreationRejection, Never>> + Send

Select exactly one concrete child host while preserving creation data in every non-accepted settlement.
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.