turnstile

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package turnstile is the smallest machine merilo checks: one mode, no actions, so Fire returns only the next machine and the outcome.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event uint8

Event is an input to Fire.

const (
	EvCoin Event
	EvPush
)

Event values.

type Machine

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

Machine is one turnstile. Build it with New and change it only with Fire.

func New

func New() Machine

New returns a locked turnstile.

func (Machine) Fire

func (m Machine) Fire(e Event) (Machine, fsm.Outcome)

Fire applies e: a coin unlocks, a push through an unlocked turnstile locks it again, and a push on a locked one is rejected.

func (Machine) State

func (m Machine) State() State

State returns the control state.

type State

type State uint8

State is the turnstile's control state.

const (
	Locked State
	Unlocked
)

State values. The zero value is an unexported sentinel.

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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