From 74e36f0ead717105f26087c2cab08b41ba5a7ce8 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Mon, 12 Feb 2024 19:18:05 +0100 Subject: All: Document everything to pass revive lint --- internal/fsm/fsm.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'internal/fsm') diff --git a/internal/fsm/fsm.go b/internal/fsm/fsm.go index f5bebd7..0fe3444 100644 --- a/internal/fsm/fsm.go +++ b/internal/fsm/fsm.go @@ -16,14 +16,17 @@ type ( StateIDSlice []StateID ) +// Len is defined here such that we can sort the slice func (v StateIDSlice) Len() int { return len(v) } +// Less is defined here such that we can sort the slice func (v StateIDSlice) Less(i, j int) bool { return v[i] < v[j] } +// Swap is defined here such that we can sort the slice func (v StateIDSlice) Swap(i, j int) { v[i], v[j] = v[j], v[i] } @@ -36,9 +39,8 @@ type Transition struct { Description string } -type ( - States map[StateID]State -) +// States is the map from state identifier to the state itself +type States map[StateID]State // State represents a single node in the graph. type State struct { @@ -97,6 +99,8 @@ func (fsm *FSM) InState(check StateID) bool { return check == fsm.Current } +// CheckTransition returns an error whether or not a transition to +// state `desired` is possible func (fsm *FSM) CheckTransition(desired StateID) error { // initial or begin state is fine // 0 = deregistered -- cgit v1.2.3