basic

package
v0.0.0-...-52cdf5e Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanToCrash

func CanToCrash(state State) bool

CanToCrash returns value if state can be change to the ToCrash.

func CanToMoving

func CanToMoving(state State) bool

CanToMoving returns value if state can be change to the ToMoving.

func CanToStay

func CanToStay(state State) bool

CanToStay returns value if state can be change to the ToStay.

func IsLastState

func IsLastState(state State) bool

IsLastState return true if no futher transitions could be done from provided state.

Types

type ProhibittedEventError

type ProhibittedEventError struct {
	State string
	Event string
}

ProhibittedEventError is error that signals that Event can't be done from State.

func (ProhibittedEventError) Error

func (e ProhibittedEventError) Error() string

type State

type State string

stay --> moving moving --> crash moving --> stay moving --> moving

const (
	Crash  State = "crash"
	Moving State = "moving"
	Stay   State = "stay"
)

func Parse

func Parse(state string) (State, error)

Parse returns corresponding state to the provided string, or error eitherise.

func ToCrash

func ToCrash(state State) (State, error)

ToCrash returns new state if it can be reached or err otherise.

func ToMoving

func ToMoving(state State) (State, error)

ToMoving returns new state if it can be reached or err otherise.

func ToStay

func ToStay(state State) (State, error)

ToStay returns new state if it can be reached or err otherise.

type UnknownStateError

type UnknownStateError struct {
	State string
}

UnknownEventError is errror that provided state not exists.

func (UnknownStateError) Error

func (e UnknownStateError) Error() string

Jump to

Keyboard shortcuts

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