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