Skip to main content

Behavior

Trait Behavior 

Source
pub trait Behavior {
    type Addr: Address;
    type Msg;
    type Event: UserEvent<Addr = Self::Addr, Message = Self::Msg>;
    type Sends: SendAlgebra;
    type Ph;
    type Error;
    type Birth: BirthMode;

    // Required methods
    fn init(&mut self) -> BehaviorActed<Self>;
    fn transition(&mut self, event: Self::Event) -> BehaviorActed<Self>;

    // Provided methods
    fn receive(
        &mut self,
        from: Self::Addr,
        message: Self::Msg,
    ) -> BehaviorActed<Self>
       where Self: Sized { ... }
    fn on<Input>(&mut self, input: Input) -> BehaviorActed<Self>
       where Self: Sized,
             Self::Event: EventInput<Input> { ... }
}
Expand description

A composed pure behavior. Event is the complete accepted protocol; every successful transition returns the declared Actions value.

Required Associated Types§

Source

type Addr: Address

Source

type Msg

Source

type Event: UserEvent<Addr = Self::Addr, Message = Self::Msg>

Source

type Sends: SendAlgebra

Source

type Ph

Source

type Error

Source

type Birth: BirthMode

Required Methods§

Source

fn init(&mut self) -> BehaviorActed<Self>

Produce initialization actions before the first event is accepted.

§Errors

Returns the behavior’s declared controlled initialization failure.

Source

fn transition(&mut self, event: Self::Event) -> BehaviorActed<Self>

Fold exactly one event into explicit actions and the next behavior.

§Errors

Returns the behavior’s declared controlled transition failure.

Provided Methods§

Source

fn receive( &mut self, from: Self::Addr, message: Self::Msg, ) -> BehaviorActed<Self>
where Self: Sized,

Fold one user communication through the composed protocol.

§Errors

Returns the behavior’s declared controlled transition failure.

Source

fn on<Input>(&mut self, input: Input) -> BehaviorActed<Self>
where Self: Sized, Self::Event: EventInput<Input>,

Inject one supported semantic input and fold it through this behavior.

This method exists only when the concrete composed protocol proves that it contains Input; unsupported lanes therefore fail to compile.

§Errors

Returns the behavior’s declared controlled transition failure.

Implementors§

Source§

impl<A, D, J, R, C> Behavior for WorkerPool<A, D, J, R, C>
where A: Address, A::Nonce: From<u64>, D: Behavior<Addr = A, Msg = PoolResponse<J, R, A>>, J: Clone, C: Behavior<Addr = A, Msg = PoolAssignment<J>, Ph = Never>,

Source§

impl<A, D, K, J, R, C, S> Behavior for KeyedWorkerPool<A, D, K, J, R, C, S>
where A: Address, A::Nonce: From<u64>, D: Behavior<Addr = A, Msg = PoolResponse<J, R, A>>, K: Eq, J: Clone, C: Behavior<Addr = A, Msg = PoolAssignment<J>, Ph = Never>, S: AffinitySelector<K, A::Nonce>,

Source§

impl<A, S, M, P, E> Behavior for Machine<A, S, M, P, E>
where A: Address, P: Copy + PartialEq,

Source§

impl<B, A, Ph, Sends, Br> Behavior for Compose<B>
where A: Address, Sends: SendAlgebra, Br: BirthMode, B: Behavior<Addr = A, Ph = Ph, Sends = Sends, Birth = Br>,

Source§

type Addr = A

Source§

type Msg = <B as Behavior>::Msg

Source§

type Event = <B as Behavior>::Event

Source§

type Sends = Sends

Source§

type Ph = Ph

Source§

type Error = <B as Behavior>::Error

Source§

type Birth = Br

Source§

impl<B, A, Ph, Sends, Br> Behavior for Deadline<B>
where A: Address, Sends: SendAlgebra, Br: BirthMode, B: Behavior<Addr = A, Ph = Ph, Sends = Sends, Birth = Br>, B::Event: TimeEvent,

Source§

type Addr = A

Source§

type Msg = <B as Behavior>::Msg

Source§

type Event = TimedEvent<<B as Behavior>::Event>

Source§

type Sends = DeadlineSends<Sends>

Source§

type Ph = Ph

Source§

type Error = <B as Behavior>::Error

Source§

type Birth = Br

Source§

impl<B, A, Ph, Sends, Br> Behavior for FinalizeOnShutdown<B>
where A: Address, Sends: SendAlgebra, Br: BirthMode, B: Behavior<Addr = A, Ph = Ph, Sends = Sends, Birth = Br>,

Source§

type Addr = A

Source§

type Msg = <B as Behavior>::Msg

Source§

type Event = ShutdownProtocol<<B as Behavior>::Event>

Source§

type Sends = Sends

Source§

type Ph = Ph

Source§

type Error = <B as Behavior>::Error

Source§

type Birth = Br

Source§

impl<B, A, Ph, Sends, Br> Behavior for ReceiveTimeout<B>
where A: Address, Sends: SendAlgebra, Br: BirthMode, B: Behavior<Addr = A, Ph = Ph, Sends = Sends, Birth = Br>, B::Event: TimeEvent,

Source§

impl<B, A, Ph, Sends, Br> Behavior for StopOnShutdown<B>
where A: Address, Sends: SendAlgebra, Br: BirthMode, B: Behavior<Addr = A, Ph = Ph, Sends = Sends, Birth = Br>,

Source§

type Addr = A

Source§

type Msg = <B as Behavior>::Msg

Source§

type Event = ShutdownProtocol<<B as Behavior>::Event>

Source§

type Sends = Sends

Source§

type Ph = Ph

Source§

type Error = <B as Behavior>::Error

Source§

type Birth = Br

Source§

impl<B, A, Ph, Sends, Br> Behavior for Watch<B>
where A: Address, Sends: SendAlgebra, Br: BirthMode, B: Behavior<Addr = A, Ph = Ph, Sends = Sends, Birth = Br>, B::Event: PeerEvent,

Source§

type Addr = A

Source§

type Msg = <B as Behavior>::Msg

Source§

type Event = WatchEvent<<B as Behavior>::Event>

Source§

type Sends = WatchSends<A, Sends>

Source§

type Ph = Ph

Source§

type Error = <B as Behavior>::Error

Source§

type Birth = Br

Source§

impl<B, A, Sends, Br> Behavior for Stash<B>
where A: Address, Sends: SendAlgebra, Br: BirthMode, B: Behavior<Addr = A, Ph = Never, Sends = Sends, Birth = Br>,

Source§

type Addr = A

Source§

type Msg = <B as Behavior>::Msg

Source§

type Event = <B as Behavior>::Event

Source§

type Sends = Sends

Source§

type Ph = Never

Source§

type Error = <B as Behavior>::Error

Source§

type Birth = Br

Source§

impl<B, C, A, Ph, Sends> Behavior for Supervisor<B, C>
where A: Address, Sends: SendAlgebra, B: Behavior<Addr = A, Ph = Ph, Sends = Sends, Birth = Births<C>>, B::Event: ChildEvent + CreationEvent + WorkerCreationEvent, A::Nonce: From<u64>, C: Behavior<Ph = Never, Addr = B::Addr>,

Source§

impl<C> Behavior for Proxy<C>
where C: Behavior<Ph = Never>, <C::Addr as Address>::Nonce: From<u64>,

Source§

impl<S, A: Address, M, Sends, Br: BirthMode, E, I, F> Behavior for BehaviorFn<S, A, M, Sends, Br, E, I, F>
where Sends: SendAlgebra, I: FnMut(&mut S) -> Acted<A, Never, Sends, Br, E>, F: FnMut(&mut S, A, M) -> Acted<A, Never, Sends, Br, E>,

Source§

type Addr = A

Source§

type Msg = M

Source§

type Event = User<A, M>

Source§

type Sends = Sends

Source§

type Ph = Never

Source§

type Error = E

Source§

type Birth = Br

Source§

impl<S, Sends, Br, E> Behavior for Pure<S, Sends, Br, E>
where S: Handler<Sends, Br, E>, Sends: SendAlgebra, Br: BirthMode,

Source§

type Addr = <S as Handler<Sends, Br, E>>::Addr

Source§

type Msg = <S as Handler<Sends, Br, E>>::Msg

Source§

type Event = User<<S as Handler<Sends, Br, E>>::Addr, <S as Handler<Sends, Br, E>>::Msg>

Source§

type Sends = Sends

Source§

type Ph = Never

Source§

type Error = E

Source§

type Birth = Br