Overview & Features
Take a quick look at the lib and its features.
Overview
State
s have all of the methods you'll need. Here's an overview:
on_start
— executed when thisState
is first pushed onto theStack
.on_stop
— executed when thisState
is popped from theStack
.on_pause
— executed when anotherState
is pushed on top of this one in theStack
.on_resume
— executed when this all of theState
s above this one are popped from theStack
.on_tick
— executed every time theStack
holding thisState
has it'stick
method called.on_shadow_tick
— same ason_tick
, but is always run independently of thisState
's position in theStack
.
To hop between State
s you'll return a Trans
ition enum
from on_tick
or similar methods, requesting the Stack
to perform such transition next tick. Here's an overview:
Trans::None
— requests theStack
to do nothing.Trans::Quit
— requests theStack
toPop
everyState
it is holding.Trans::Push(Box::new(State))
— requests theStack
toPush
the providedState
on top.Trans::Pop
— requests theStack
to pop the topmostState
it is holding, deleting it.Trans::Replace(Box::new(State))
— requests theStack
toPop
once andPush
the providedState
.Trans::Isolate(Box::new(State))
— requests theStack
toPop
everything andPush
the providedState
.
Transitions may be requested directly of the
Stack
or by returning aTrans
from inside aon_tick
oron_shadow_tick
method of aState
.
Features
An easy to implement
State
trait
.An easy to use State
Stack
Machinestruct
.An easy to use set of
Trans
itions betweenStates
.New in
v0.3.0
:on_shadow_tick
is provided onState
s; similar toon_tick
but is always executed independently of theState
's position in theStack
.
Last updated