pub trait Action {
type Input;
// Required method
fn execute(&self, input: &mut Self::Input);
}
Expand description
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.
Required Associated Types§
Required Methods§
Sourcefn execute(&self, input: &mut Self::Input)
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;
}
}