[][src]Trait automafish::Action

pub trait Action {
    type Input;
    pub fn execute(&self, input: &mut Self::Input);
}

Action that may be executed when entering a state.

See ActionMut if you need an action that may mutate its internal state. The Action is implemented for Box<Fn(T)> by default.

Associated Types

type Input

Input type for the action.

Loading content...

Required methods

pub fn execute(&self, input: &mut Self::Input)

Perform the action in the input.

Note that the input takes the input type as a reference to allow multiple actions to be executed on it if necessary. This doesn't prevent mutating the input though, since the Input itself can be defined as &mut Foo.

Examples

struct IncrementValue;
impl Action for IncrementValue {
    type Input = u32;
    fn execute(&self, input: &mut Self::Input) {
        *input += 1;
    }
}
Loading content...

Implementations on Foreign Types

impl<T> Action for Box<dyn Fn(&mut T)>[src]

type Input = T

Loading content...

Implementors

Loading content...