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:
ⓘ
use behavior::{
Actions, Behavior, BehaviorActed, Births, ChildChoice, ChildHead,
ChildRole, MailAddr, Never, NoBirths, User,
};
struct CacheWorker;
struct QueueWorker;
struct Parent;
macro_rules! inert {
($actor:ty) => {
impl behavior::Protocol for $actor {
type Addr = MailAddr;
type Msg = Never;
}
impl Behavior for $actor {
type Protocol = Self;
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!(CacheWorker);
inert!(QueueWorker);
impl behavior::Protocol for Parent {
type Addr = MailAddr;
type Msg = Never;
}
impl Behavior for Parent {
type Protocol = Self;
type Event = User<MailAddr, Never>;
type Sends = Vec<Never>;
type Ph = Never;
type Error = Never;
type Birth = Births<ChildChoice<QueueWorker, ChildChoice<CacheWorker, Never>>>;
fn transition(&mut self, _: behavior::ActiveTurn, event: Self::Event) -> BehaviorActed<Self> {
match event.message {}
}
}
struct ForgedCacheRole;
impl ChildRole<Parent> for ForgedCacheRole {
type Child = CacheWorker;
type Position = ChildHead;
}Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".