Skip to main content

ShutdownChild

Struct ShutdownChild 

Source
pub struct ShutdownChild<C: Behavior, Occurrence> {
    pub child: CreationId,
    pub ingress: Ingress<ShutdownRequested, Here>,
    /* private fields */
}
Expand description

Ask the local interpreter to begin orderly shutdown of one established child of protocol C in the emitting actor’s namespace.

Acceptance is not completion. A successfully accepted request is completed only by the corresponding ChildStopped fact. If the interpreter cannot select an established C child, it must return ChildShutdownRejected rather than fabricate termination or fail the whole action application. Protocol identity is retained in the type even when two child protocols use the same address and nonce types:

ⓘ
struct Queue;
struct Worker;
macro_rules! inert {
    ($actor:ty) => {
        impl behavior::Protocol for $actor {
            type Addr = behavior::MailAddr;
            type Msg = u8;
        }
        impl behavior::Behavior for $actor {
            type Protocol = Self;
            type Event = behavior::User<behavior::MailAddr, u8>;
            type Sends = Vec<behavior::Never>;
            type Ph = behavior::Never;
            type Error = behavior::Never;
            type Birth = behavior::NoBirths;
            fn init(&mut self, _: behavior::InitializationTurn) -> behavior::BehaviorActed<Self> {
                Ok(behavior::Actions::cont())
            }
            fn transition(&mut self, _: behavior::ActiveTurn, _: Self::Event) -> behavior::BehaviorActed<Self> {
                Ok(behavior::Actions::cont())
            }
        }
    };
}
inert!(Queue);
inert!(Worker);

let child = behavior::CreationSequence::new()
    .issue()
    .expect("the first creation ID exists");
let queue = behavior_actors::ShutdownChild::<Queue, behavior::ChildHead>::new(child);
let _: behavior_actors::ShutdownChild<Worker, behavior::ChildHead> = queue;

Repeated occurrences of the same behavior are also incompatible:

ⓘ
struct Worker;
impl behavior::Protocol for Worker {
    type Addr = behavior::MailAddr;
    type Msg = ();
}
impl behavior::Behavior for Worker {
    type Protocol = Self;
    type Event = behavior::User<behavior::MailAddr, ()>;
    type Sends = Vec<behavior::Never>;
    type Ph = behavior::Never;
    type Error = behavior::Never;
    type Birth = behavior::NoBirths;
    fn transition(
        &mut self,
        _: behavior::ActiveTurn,
        _: Self::Event,
    ) -> behavior::BehaviorActed<Self> {
        Ok(behavior::Actions::cont())
    }
}
let child = behavior::CreationSequence::new()
    .issue()
    .expect("the first creation ID exists");
let first = behavior_actors::ShutdownChild::<Worker, behavior::ChildHead>::new(child);
let _: behavior_actors::ShutdownChild<Worker, behavior::ChildTail<behavior::ChildHead>> = first;

Fields§

§child: CreationId§ingress: Ingress<ShutdownRequested, Here>

Exact shutdown owner in the selected child behavior.

Implementations§

Source§

impl<C: Behavior, Occurrence> ShutdownChild<C, Occurrence>

Source

pub const fn new(child: CreationId) -> Self

Trait Implementations§

Source§

impl<C, Occurrence> ActionItem for ShutdownChild<C, Occurrence>
where C: Behavior, <BehaviorAddr<C> as Address>::Nonce: Send,

Source§

type Custody = (Option<ShutdownChild<C, Occurrence>>, Option<<ShutdownChild<C, Occurrence> as ActionItem>::Reply>)

Source§

type Input<'a> = &'a mut Option<ShutdownChild<C, Occurrence>> where Self: 'a

Source§

type Reply = ItemSettlement<ShutdownChild<C, Occurrence>, <ShutdownChild<C, Occurrence> as ActionItem>::Accepted, <ShutdownChild<C, Occurrence> as ActionItem>::Rejection, <ShutdownChild<C, Occurrence> as ActionItem>::Prerequisite>

Source§

type Accepted = ()

Source§

type Rejection = ChildShutdownRejection

Source§

type Prerequisite = CreationCorrelation<<C as Behavior>::Protocol, Occurrence>

Source§

fn prepare_interpretation( progress: &mut Option<InterpretationProgress<Self, Self::Custody, Self::Reply>>, )

Source§

fn interpretation_input<'a>( custody: &'a mut Self::Custody, ) -> Option<(Self::Input<'a>, &'a mut Option<Self::Reply>)>
where Self: 'a,

Source§

fn finish_interpretation( progress: &mut Option<InterpretationProgress<Self, Self::Custody, Self::Reply>>, )

Source§

fn retain_accepted(_: Self::Accepted) -> Option<Self::Accepted>

Keep an accepted value only while it still carries terminal custody. Read more
Source§

impl<C: Behavior, Occurrence> Clone for ShutdownChild<C, Occurrence>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: Behavior, Occurrence> Debug for ShutdownChild<C, Occurrence>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C: Behavior, Occurrence> InterpreterRequest for ShutdownChild<C, Occurrence>

Source§

impl<C: Behavior, Occurrence> PartialEq for ShutdownChild<C, Occurrence>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<C: Behavior, Occurrence> Copy for ShutdownChild<C, Occurrence>

Source§

impl<C: Behavior, Occurrence> Eq for ShutdownChild<C, Occurrence>

Auto Trait Implementations§

§

impl<C, Occurrence> Freeze for ShutdownChild<C, Occurrence>

§

impl<C, Occurrence> RefUnwindSafe for ShutdownChild<C, Occurrence>

§

impl<C, Occurrence> Send for ShutdownChild<C, Occurrence>

§

impl<C, Occurrence> Sync for ShutdownChild<C, Occurrence>

§

impl<C, Occurrence> Unpin for ShutdownChild<C, Occurrence>

§

impl<C, Occurrence> UnsafeUnpin for ShutdownChild<C, Occurrence>

§

impl<C, Occurrence> UnwindSafe for ShutdownChild<C, Occurrence>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.