Skip to main content

BehaviorFn

Struct BehaviorFn 

Source
pub struct BehaviorFn<S, A, M, Sends, Br, E, I, F>
where A: Address, Br: BirthMode,
{ /* private fields */ }
Expand description

A concrete behavior defined by initialization and user-event folds.

Each function is invoked exactly once for its corresponding input and its returned Actions value is preserved unchanged. This adapter adds no event routing or effect interpretation; those remain the responsibility of concrete behavior wrappers and the runtime interpreter.

Implementations§

Source§

impl<S, A, M, Sends, Br, E, I, F> 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

pub fn new( state: S, initialize: I, transition: F, ) -> BehaviorFn<S, A, M, Sends, Br, E, I, F>

Source

pub fn state(&self) -> &S

Trait Implementations§

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§

fn init( &mut self, ) -> Result<Actions<<BehaviorFn<S, A, M, Sends, Br, E, I, F> as Behavior>::Addr, <BehaviorFn<S, A, M, Sends, Br, E, I, F> as Behavior>::Ph, <BehaviorFn<S, A, M, Sends, Br, E, I, F> as Behavior>::Sends, <BehaviorFn<S, A, M, Sends, Br, E, I, F> as Behavior>::Birth>, <BehaviorFn<S, A, M, Sends, Br, E, I, F> as Behavior>::Error>

Produce initialization actions before the first event is accepted. Read more
Source§

fn transition( &mut self, event: <BehaviorFn<S, A, M, Sends, Br, E, I, F> as Behavior>::Event, ) -> Result<Actions<<BehaviorFn<S, A, M, Sends, Br, E, I, F> as Behavior>::Addr, <BehaviorFn<S, A, M, Sends, Br, E, I, F> as Behavior>::Ph, <BehaviorFn<S, A, M, Sends, Br, E, I, F> as Behavior>::Sends, <BehaviorFn<S, A, M, Sends, Br, E, I, F> as Behavior>::Birth>, <BehaviorFn<S, A, M, Sends, Br, E, I, F> as Behavior>::Error>

Fold exactly one event into explicit actions and the next behavior. Read more
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. Read more
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. Read more

Auto Trait Implementations§

§

impl<S, A, M, Sends, Br, E, I, F> Freeze for BehaviorFn<S, A, M, Sends, Br, E, I, F>
where S: Freeze, I: Freeze, F: Freeze,

§

impl<S, A, M, Sends, Br, E, I, F> RefUnwindSafe for BehaviorFn<S, A, M, Sends, Br, E, I, F>

§

impl<S, A, M, Sends, Br, E, I, F> Send for BehaviorFn<S, A, M, Sends, Br, E, I, F>
where S: Send, I: Send, F: Send,

§

impl<S, A, M, Sends, Br, E, I, F> Sync for BehaviorFn<S, A, M, Sends, Br, E, I, F>
where S: Sync, I: Sync, F: Sync,

§

impl<S, A, M, Sends, Br, E, I, F> Unpin for BehaviorFn<S, A, M, Sends, Br, E, I, F>
where S: Unpin, I: Unpin, F: Unpin,

§

impl<S, A, M, Sends, Br, E, I, F> UnsafeUnpin for BehaviorFn<S, A, M, Sends, Br, E, I, F>

§

impl<S, A, M, Sends, Br, E, I, F> UnwindSafe for BehaviorFn<S, A, M, Sends, Br, E, I, F>
where S: UnwindSafe, I: UnwindSafe, F: UnwindSafe,

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> 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, 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.