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,
    ) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>;
    fn transition(
        &mut self,
        event: Self::Event,
    ) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>;

    // Provided methods
    fn receive(
        &mut self,
        from: Self::Addr,
        message: Self::Msg,
    ) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>
       where Self: Sized { ... }
    fn on<Input>(
        &mut self,
        input: Input,
    ) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>
       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, ) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>

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, ) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>

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, ) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>
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, ) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>
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.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

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

Source§

impl<A, K, J, R, C, S> Behavior for KeyedWorkerPool<A, K, J, R, C, S>
where A: Address, <A as Address>::Nonce: From<u64>, K: Eq, J: Clone, C: Behavior<Addr = A, Msg = PoolAssignment<J>, Ph = Never>, S: AffinitySelector<K, <A as Address>::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 as Behavior>::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 as Behavior>::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 as Behavior>::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 Sends: SendAlgebra, B: Behavior<Addr = A, Ph = Ph, Sends = Sends, Birth = Births<C>>, <B as Behavior>::Event: ChildEvent + CreationEvent + WorkerCreationEvent, <A as Address>::Nonce: From<u64>, C: Behavior<Ph = Never, Addr = <B as Behavior>::Addr>, A: Address,

Source§

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

Source§

impl<S, A, M, Sends, Br, E, I, F> Behavior for BehaviorFn<S, A, M, Sends, Br, E, I, F>
where A: Address, Br: BirthMode, Sends: SendAlgebra, I: FnMut(&mut S) -> Result<Actions<A, Never, Sends, Br>, E>, F: FnMut(&mut S, A, M) -> Result<Actions<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, O, Br, E> Behavior for Pure<S, O, Br, E>
where S: Handler<O, Br, E>, Br: BirthMode,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

type Ph = Never

Source§

type Error = E

Source§

type Birth = Br