fsm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: GPL-3.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fsm provides protocol state machine extraction and visualization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State struct {
	Name    string `json:"name"`
	Initial bool   `json:"initial,omitempty"`
	Final   bool   `json:"final,omitempty"`
}

State represents a protocol state.

type StateMachine

type StateMachine struct {
	Protocol    string       `json:"protocol"`
	States      []State      `json:"states"`
	Transitions []Transition `json:"transitions"`
}

StateMachine represents a protocol state machine.

func NewStateMachine

func NewStateMachine(protocol string) *StateMachine

NewStateMachine creates a new state machine.

func (*StateMachine) AddState

func (sm *StateMachine) AddState(name string, initial, final bool)

AddState adds a state.

func (*StateMachine) AddTransition

func (sm *StateMachine) AddTransition(from, to, event string)

AddTransition adds a transition.

func (*StateMachine) Coverage

func (sm *StateMachine) Coverage(observed []string) float64

Coverage calculates state coverage from observed transitions.

func (*StateMachine) ToDOT

func (sm *StateMachine) ToDOT() string

ToDOT generates a Graphviz DOT diagram.

func (*StateMachine) ToMermaid

func (sm *StateMachine) ToMermaid() string

ToMermaid generates a Mermaid state diagram.

type Transition

type Transition struct {
	From      string `json:"from"`
	To        string `json:"to"`
	Event     string `json:"event"`
	Condition string `json:"condition,omitempty"`
}

Transition represents a state transition.

Jump to

Keyboard shortcuts

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