aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/app_linux.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-28 01:07:51 +0900
committerOphestra <cat@gensokyo.uk>2025-08-28 01:07:51 +0900
commitb14690aa77b3d5f86c4d1b1965675d6d82789e32 (patch)
tree5765f705fd69dae7a65a0666451ac71a729a6aa8 /internal/app/app_linux.go
parentd0b6852cd7db2bb1214c3267719d3ac108c0a53e (diff)
internal/app: remove seal interface
This further cleans up the package for the restructure. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/app_linux.go')
-rw-r--r--internal/app/app_linux.go81
1 files changed, 0 insertions, 81 deletions
diff --git a/internal/app/app_linux.go b/internal/app/app_linux.go
deleted file mode 100644
index eebfacdc..00000000
--- a/internal/app/app_linux.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package app
-
-import (
- "context"
- "fmt"
- "log"
- "sync"
-
- "hakurei.app/hst"
- "hakurei.app/internal/app/state"
- "hakurei.app/internal/sys"
-)
-
-func New(ctx context.Context, os sys.State) (*App, error) {
- a := new(App)
- a.sys = os
- a.ctx = ctx
-
- id := new(state.ID)
- err := state.NewAppID(id)
- a.id = newID(id)
-
- return a, err
-}
-
-func MustNew(ctx context.Context, os sys.State) *App {
- a, err := New(ctx, os)
- if err != nil {
- log.Fatalf("cannot create app: %v", err)
- }
- return a
-}
-
-type App struct {
- id *stringPair[state.ID]
- sys sys.State
- ctx context.Context
-
- *outcome
- mu sync.RWMutex
-}
-
-// ID returns a copy of [state.ID] held by App.
-func (a *App) ID() state.ID { a.mu.RLock(); defer a.mu.RUnlock(); return a.id.unwrap() }
-
-func (a *App) String() string {
- if a == nil {
- return "(invalid app)"
- }
-
- a.mu.RLock()
- defer a.mu.RUnlock()
-
- if a.outcome != nil {
- if a.outcome.user.uid == nil {
- return fmt.Sprintf("(sealed app %s with invalid uid)", a.id)
- }
- return fmt.Sprintf("(sealed app %s as uid %s)", a.id, a.outcome.user.uid)
- }
-
- return fmt.Sprintf("(unsealed app %s)", a.id)
-}
-
-// Seal determines the outcome of [hst.Config] as a [SealedApp].
-// Values stored in and referred to by [hst.Config] might be overwritten and must not be used again.
-func (a *App) Seal(config *hst.Config) (SealedApp, error) {
- a.mu.Lock()
- defer a.mu.Unlock()
-
- if a.outcome != nil {
- panic("app sealed twice")
- }
-
- seal := new(outcome)
- seal.id = a.id
- err := seal.finalise(a.ctx, a.sys, config)
- if err == nil {
- a.outcome = seal
- }
- return seal, err
-}