summaryrefslogtreecommitdiff
path: root/internal/fsm/fsm.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2024-02-12 19:18:05 +0100
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2024-02-19 14:15:07 +0100
commit74e36f0ead717105f26087c2cab08b41ba5a7ce8 (patch)
tree1eb2b7516bea705c9b5a50ce0965e170414ed880 /internal/fsm/fsm.go
parent682d70091af2044ff6d8b350da9dff13163232e2 (diff)
All: Document everything to pass revive lint
Diffstat (limited to 'internal/fsm/fsm.go')
-rw-r--r--internal/fsm/fsm.go10
1 files changed, 7 insertions, 3 deletions
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