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,
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>
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
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
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>>
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>
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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<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
impl<Head: Eq, Tail: Eq> Eq for ChildChoice<Head, Tail>
impl<Head, Tail> 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<Node> BirthNodeAppend<Never> for Nodewhere
Node: NonEmptyBirthNode,
impl<Node> BirthNodeAppend<Never> for Nodewhere
Node: NonEmptyBirthNode,
Source§type Output = Node
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
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
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>>
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> 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
Source§impl<Node, Shape> ChildOccurrenceProduct<Shape> for Nodewhere
Node: ChildOccurrenceProductAt<ChildHead, Shape>,
Shape: ChildOccurrenceShape,
impl<Node, Shape> ChildOccurrenceProduct<Shape> for Nodewhere
Node: ChildOccurrenceProductAt<ChildHead, Shape>,
Shape: ChildOccurrenceShape,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<A, Child, Host> DispatchBirth<A, Host> for Child
impl<A, Child, Host> DispatchBirth<A, Host> for Child
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
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.