Skip to main content

ChildOccurrenceMember

Trait ChildOccurrenceMember 

Source
pub trait ChildOccurrenceMember<Occurrence, Child: Behavior, Tail>: ChildOccurrenceShape {
    type Member;
}
Expand description

Shape-owned eligibility and representation of one exact child occurrence.

An interpreter may require the payload contracts its storage actually owns. Those requirements govern this projection, not pure actor declarations.

Eligibility is required independently at each inhabited occurrence. A shape admitting only the tail cannot supply the head:

ⓘ
struct NoChildren;
struct OccurrenceSlot<Position, Child, Tail> {
    child: Child,
    tail: Tail,
    position: std::marker::PhantomData<fn() -> Position>,
}
struct Worker { payload: u32 }
impl behavior::Protocol for Worker {
    type Addr = behavior::MailAddr;
    type Msg = behavior::Never;
}
impl behavior::Behavior for Worker {
    type Protocol = Self;
    type Event = behavior::User<behavior::MailAddr, behavior::Never>;
    type Sends = behavior::NoSends;
    type Birth = behavior::NoBirths;
    type Ph = behavior::Never;
    type Error = behavior::Never;
    fn transition(&mut self, _: behavior::ActiveTurn, event: Self::Event)
        -> behavior::BehaviorActed<Self> {
        match event.message {}
    }
}
type Workers = behavior::ChildChoice<Worker, behavior::ChildChoice<Worker, behavior::Never>>;
struct MissingHead;
impl behavior::ChildOccurrenceShape for MissingHead {
    type Empty = NoChildren;
}
impl<Child: behavior::Behavior, Tail> behavior::ChildOccurrenceMember<behavior::ChildTail<behavior::ChildHead>, Child, Tail> for MissingHead {
    type Member = OccurrenceSlot<behavior::ChildTail<behavior::ChildHead>, Child, Tail>;
}
let _: std::marker::PhantomData<behavior::ChildOccurrences<Workers, MissingHead>> = std::marker::PhantomData;

A shape admitting only the head cannot supply the tail:

ⓘ
struct NoChildren;
struct OccurrenceSlot<Position, Child, Tail> {
    child: Child,
    tail: Tail,
    position: std::marker::PhantomData<fn() -> Position>,
}
struct Worker { payload: u32 }
impl behavior::Protocol for Worker {
    type Addr = behavior::MailAddr;
    type Msg = behavior::Never;
}
impl behavior::Behavior for Worker {
    type Protocol = Self;
    type Event = behavior::User<behavior::MailAddr, behavior::Never>;
    type Sends = behavior::NoSends;
    type Birth = behavior::NoBirths;
    type Ph = behavior::Never;
    type Error = behavior::Never;
    fn transition(&mut self, _: behavior::ActiveTurn, event: Self::Event)
        -> behavior::BehaviorActed<Self> {
        match event.message {}
    }
}
type Workers = behavior::ChildChoice<Worker, behavior::ChildChoice<Worker, behavior::Never>>;
struct MissingTail;
impl behavior::ChildOccurrenceShape for MissingTail {
    type Empty = NoChildren;
}
impl<Child: behavior::Behavior, Tail> behavior::ChildOccurrenceMember<behavior::ChildHead, Child, Tail> for MissingTail {
    type Member = OccurrenceSlot<behavior::ChildHead, Child, Tail>;
}
let _: std::marker::PhantomData<behavior::ChildOccurrences<Workers, MissingTail>> = std::marker::PhantomData;

Required Associated Types§

Source

type Member

Storage for this child, its static occurrence, and the remaining product.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§