fsm

package module
v0.0.0-...-23f1c64 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2024 License: MIT Imports: 3 Imported by: 0

README

fsm

A toy fsm implementation in go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownState      = errors.New("state not in list")
	ErrUnknownEvent      = errors.New("event not in list")
	ErrUnknownStart      = errors.New("start not in the state list")
	ErrTerminalState     = errors.New("fsm in terminal state.")
	ErrUnknownTransition = errors.New("transition with given event/state not in list")
)

Functions

This section is empty.

Types

type Event

type Event int

type EventState

type EventState struct {
	Event Event
	Next  State
}

type FSM

type FSM struct {
	// contains filtered or unexported fields
}

func NewFSM

func NewFSM(states []State, events []Event, start State, transitions ...Transition) (*FSM, error)

func (*FSM) Current

func (fsm *FSM) Current() State

func (*FSM) Transition

func (fsm *FSM) Transition(event Event) (State, error)

type State

type State int

type Transition

type Transition struct {
	State       State
	EventStates []EventState
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL