Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Blueprint ¶
type Blueprint struct {
// contains filtered or unexported fields
}
func (*Blueprint) Add ¶
func (b *Blueprint) Add(t *Transition)
Add adds a complete transition to the blueprint.
func (*Blueprint) From ¶
func (b *Blueprint) From(start uint8) *Transition
From returns a new transition for the blueprint. The transition will be added to the blueprint automatically when it has both "from" and "to" values.
type Handler ¶
type Handler func(m *Machine)
Handler represents a callback to be called when the machine performs a certain transition between states.
type Machine ¶
type Machine struct {
// contains filtered or unexported fields
}
Machine represents a finite state machine. Instances of this struct should not be constructed by hand and instead should be created using a blueprint.
func (*Machine) Disallows ¶
Disallows returns whether or not this machine can't transition to the state b.
type Transition ¶
type Transition struct {
// contains filtered or unexported fields
}
Transition represents a transition between two states.
func (*Transition) From ¶
func (t *Transition) From(from uint8) *Transition
From sets the source state of the transition.
func (*Transition) Then ¶
func (t *Transition) Then(fn Handler) *Transition
Then sets the callback function for when the transition has occurred.
func (*Transition) To ¶
func (t *Transition) To(to uint8) *Transition
To sets the destination state of the transition.