pub trait ResolveChildOccurrence<Occurrence>: Behavior + ResolveChildOccurrence<Occurrence> {
type Child: Behavior;
type Position: ChildPosition<<Self::Birth as BirthMode>::Child, Self::Child>;
}Expand description
Resolve an effect’s nominal or structural occurrence against the concrete behavior currently being interpreted.
This is a sealed, type-level derived construction. It performs no lookup,
allocates no actor, and introduces no second identity: the resolved child’s
Behavior::Protocol remains canonical identity, while Position is only
navigation evidence into the emitter’s direct birth algebra.
A nominal role follows BehaviorBase through a wrapper only when the
wrapper preserves the exact protocol and the role’s declared child at its
exact structural position. A wrapper may append births after that position,
but it cannot replace, reorder, or insert births before it. Raw
ChildHead and ChildTail positions instead resolve directly against
the running emitter’s own birth algebra.
A wrapper that replaces its base role’s child cannot silently reuse that role:
use behavior::{
Actions, Behavior, BehaviorActed, BehaviorBase, Births, ChildHead,
ChildOccurrence, ChildRole, DeclaredChildOccurrence, MailAddr, Never,
NoBirths, NoSends, Protocol, ResolveChildOccurrence,
};
struct ActorProtocol;
impl Protocol for ActorProtocol {
type Addr = MailAddr;
type Msg = Never;
}
macro_rules! inert {
($actor:ident, $birth:ty) => {
struct $actor;
impl Behavior for $actor {
type Protocol = ActorProtocol;
type Event = Never;
type Sends = NoSends;
type Ph = Never;
type Error = Never;
type Birth = $birth;
fn transition(
&mut self,
_: behavior::ActiveTurn,
event: Never,
) -> BehaviorActed<Self> {
match event {}
}
}
};
}
inert!(Child, NoBirths);
inert!(Proxy, NoBirths);
inert!(Parent, Births<Child>);
inert!(ChangedTopology, Births<Proxy>);
impl BehaviorBase for Parent {
type Base = Self;
fn base(&self) -> &Self { self }
}
impl BehaviorBase for ChangedTopology {
type Base = Parent;
fn base(&self) -> &Parent { unreachable!() }
}
struct WorkerRole;
impl ChildRole<Parent> for WorkerRole {
type Child = Child;
type Position = ChildHead;
}
impl ChildOccurrence<Parent> for WorkerRole {
type Resolution = DeclaredChildOccurrence;
}
fn require<T: ResolveChildOccurrence<WorkerRole>>() {}
require::<ChangedTopology>();Required Associated Types§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".