Documentation
¶
Overview ¶
Package enum holds the storage and JSON codec shared by small state enums: a uint8 whose values run 1..n, each spelled by one word. A type keeps its own constants, names table and transition rules, and forwards its String, Parse, Value, Scan and JSON methods here in one line each.
Index ¶
- type Set
- func (s Set[T]) JSON(v T) ([]byte, error)
- func (s Set[T]) Parse(text string) (T, error)
- func (s Set[T]) ReadJSON(dst *T, data []byte) error
- func (s Set[T]) Scan(dst *T, value any) error
- func (s Set[T]) String(v T) string
- func (s Set[T]) Valid(v T) bool
- func (s Set[T]) Value(v T) (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[T ~uint8] struct { // Names spells each value: Names[i] is the word for T(i+1). Names []string // Invalid is what String returns for a value outside the set. Invalid string // Err is wrapped by every parse, range and scan error, so callers can // test for it with errors.Is. Err error // ScanLabel names a non-text database value in a Scan error, such as // "value" or "database value". ScanLabel string }
Set is the codec of one enum type. The zero value of T is never valid.
func (Set[T]) Scan ¶
Scan reads a stored word into dst. Only text is accepted: NULL and other types are errors, and dst is left unchanged on any error.
Click to show internal directories.
Click to hide internal directories.