Overview & Features
Take a quick look at the lib and its features.
Overview
States have all of the methods you'll need. Here's an overview:
on_start— executed when thisStateis first pushed onto theStack.on_stop— executed when thisStateis popped from theStack.on_pause— executed when anotherStateis pushed on top of this one in theStack.on_resume— executed when this all of theStates above this one are popped from theStack.on_tick— executed every time theStackholding thisStatehas it'stickmethod called.on_shadow_tick— same ason_tick, but is always run independently of thisState's position in theStack.
To hop between States you'll return a Transition enum from on_tick or similar methods, requesting the Stack to perform such transition next tick. Here's an overview:
Trans::None— requests theStackto do nothing.Trans::Quit— requests theStacktoPopeveryStateit is holding.Trans::Push(Box::new(State))— requests theStacktoPushthe providedStateon top.Trans::Pop— requests theStackto pop the topmostStateit is holding, deleting it.Trans::Replace(Box::new(State))— requests theStacktoPoponce andPushthe providedState.Trans::Isolate(Box::new(State))— requests theStacktoPopeverything andPushthe providedState.
Transitions may be requested directly of the
Stackor by returning aTransfrom inside aon_tickoron_shadow_tickmethod of aState.
Features
An easy to implement
Statetrait.An easy to use State
StackMachinestruct.An easy to use set of
Transitions betweenStates.New in
v0.3.0:on_shadow_tickis provided onStates; similar toon_tickbut is always executed independently of theState's position in theStack.
Last updated