pub trait ChildPosition<Children, Child: Behavior>: ChildPosition { }Expand description
Static proof that Child occupies Position in a closed child sum.
This trait provides structural evidence only. It does not construct a choice, perform creation, or select a child through runtime inspection. A role cannot claim a position occupied by a different child:
ⓘ
struct CacheWorker;
struct QueueWorker;
struct Parent;
macro_rules! inert {
($actor:ty) => {
impl behavior::Protocol for $actor {
type Addr = behavior::MailAddr;
type Msg = behavior::Never;
}
impl behavior::Behavior for $actor {
type Protocol = Self;
type Event = behavior::User<behavior::MailAddr, behavior::Never>;
type Sends = Vec<behavior::Never>;
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);
impl behavior::Protocol for Parent {
type Addr = behavior::MailAddr;
type Msg = behavior::Never;
}
impl behavior::Behavior for Parent {
type Protocol = Self;
type Event = behavior::User<behavior::MailAddr, behavior::Never>;
type Sends = Vec<behavior::Never>;
type Ph = behavior::Never;
type Error = behavior::Never;
type Birth = behavior::Births<behavior::ChildChoice<QueueWorker, behavior::ChildChoice<CacheWorker, behavior::Never>>>;
fn transition(&mut self, _: behavior::ActiveTurn, event: Self::Event) -> behavior::BehaviorActed<Self> {
match event.message {}
}
}
struct ForgedCacheRole;
impl behavior::ChildRole<Parent> for ForgedCacheRole {
type Child = CacheWorker;
type Position = behavior::ChildHead;
}