hst/enablement: move bits from system
All checks were successful
Test / Create distribution (push) Successful in 54s
Test / Sandbox (push) Successful in 2m33s
Test / Hakurei (push) Successful in 3m36s
Test / Hpkg (push) Successful in 4m30s
Test / Sandbox (race detector) (push) Successful in 4m48s
Test / Hakurei (race detector) (push) Successful in 5m47s
Test / Flake checks (push) Successful in 1m40s
All checks were successful
Test / Create distribution (push) Successful in 54s
Test / Sandbox (push) Successful in 2m33s
Test / Hakurei (push) Successful in 3m36s
Test / Hpkg (push) Successful in 4m30s
Test / Sandbox (race detector) (push) Successful in 4m48s
Test / Hakurei (race detector) (push) Successful in 5m47s
Test / Flake checks (push) Successful in 1m40s
This is part of the hst API, should not be in the implementation package. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -7,11 +7,12 @@ import (
|
||||
"strings"
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/hst"
|
||||
)
|
||||
|
||||
const (
|
||||
// User type is reverted at final instance exit.
|
||||
User = EM << iota
|
||||
User = hst.EM << iota
|
||||
// Process type is unconditionally reverted on exit.
|
||||
Process
|
||||
|
||||
@@ -19,21 +20,21 @@ const (
|
||||
)
|
||||
|
||||
// Criteria specifies types of Op to revert.
|
||||
type Criteria Enablement
|
||||
type Criteria hst.Enablement
|
||||
|
||||
func (ec *Criteria) hasType(t Enablement) bool {
|
||||
func (ec *Criteria) hasType(t hst.Enablement) bool {
|
||||
// nil criteria: revert everything except User
|
||||
if ec == nil {
|
||||
return t != User
|
||||
}
|
||||
|
||||
return Enablement(*ec)&t != 0
|
||||
return hst.Enablement(*ec)&t != 0
|
||||
}
|
||||
|
||||
// Op is a reversible system operation.
|
||||
type Op interface {
|
||||
// Type returns [Op]'s enablement type, for matching a revert criteria.
|
||||
Type() Enablement
|
||||
Type() hst.Enablement
|
||||
|
||||
apply(sys *I) error
|
||||
revert(sys *I, ec *Criteria) error
|
||||
@@ -44,7 +45,7 @@ type Op interface {
|
||||
}
|
||||
|
||||
// TypeString extends [Enablement.String] to support [User] and [Process].
|
||||
func TypeString(e Enablement) string {
|
||||
func TypeString(e hst.Enablement) string {
|
||||
switch e {
|
||||
case User:
|
||||
return "user"
|
||||
|
||||
Reference in New Issue
Block a user