aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/state/id.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-23 22:51:10 +0900
committerOphestra <cat@gensokyo.uk>2025-10-23 22:59:02 +0900
commitdd94818f20c7a37bdd7c6129551759db1b09b65e (patch)
tree1ea7c94b3f6aec92f037a3e58dc343c3b00cd5a2 /internal/app/state/id.go
parent0fd357e7f64ec029489bbbcc7935005a26cb9a13 (diff)
hst/instance: define instance state
This is now part of the hst API. This change also improves identifier generation and serialisation. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/state/id.go')
-rw-r--r--internal/app/state/id.go48
1 files changed, 0 insertions, 48 deletions
diff --git a/internal/app/state/id.go b/internal/app/state/id.go
deleted file mode 100644
index 11bbc3fe..00000000
--- a/internal/app/state/id.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package state
-
-import (
- "crypto/rand"
- "encoding/hex"
- "errors"
- "fmt"
-)
-
-type ID [16]byte
-
-var (
- ErrInvalidLength = errors.New("string representation must have a length of 32")
-)
-
-func (a *ID) String() string {
- return hex.EncodeToString(a[:])
-}
-
-func NewAppID(id *ID) error {
- _, err := rand.Read(id[:])
- return err
-}
-
-func ParseAppID(id *ID, s string) error {
- if len(s) != 32 {
- return ErrInvalidLength
- }
-
- for i, b := range s {
- if b < '0' || b > 'f' {
- return fmt.Errorf("invalid char %q at byte %d", b, i)
- }
-
- v := uint8(b)
- if v > '9' {
- v = 10 + v - 'a'
- } else {
- v -= '0'
- }
- if i%2 == 0 {
- v <<= 4
- }
- id[i/2] += v
- }
-
- return nil
-}