Add "Interfaces"

Virgil 2026-02-19 17:30:02 +00:00
parent 4bc9e11c7c
commit cdb7ab6108

80
Interfaces.md Normal file

@ -0,0 +1,80 @@
# Interfaces
Core defines several interfaces for service contracts. Services register implementations; consumers retrieve via `ServiceFor[T]()`.
## Lifecycle
```go
type Startable interface {
OnStartup(ctx context.Context) error
}
type Stoppable interface {
OnShutdown(ctx context.Context) error
}
```
## Config
```go
type Config interface {
Get(key string, out any) error
Set(key string, v any) error
}
```
## Display
```go
type Display interface {
OpenWindow(opts ...WindowOption) error
}
```
## Workspace
```go
type Workspace interface {
CreateWorkspace(identifier, password string) (string, error)
SwitchWorkspace(name string) error
WorkspaceFileGet(filename string) (string, error)
WorkspaceFileSet(filename, content string) error
}
```
## Crypt
```go
type Crypt interface {
CreateKeyPair(name, passphrase string) (string, error)
EncryptPGP(writer io.Writer, recipientPath, data string, opts ...any) (string, error)
DecryptPGP(recipientPath, message, passphrase string, opts ...any) (string, error)
}
```
## TaskWithID
For tasks that need progress reporting:
```go
type TaskWithID interface {
Task
SetTaskID(id string)
GetTaskID() string
}
```
## Abstract Storage (pkg/io)
```go
type Medium interface {
Read(path string) (string, error)
Write(path, content string) error
List(path string) ([]fs.DirEntry, error)
Delete(path string) error
}
```
Implementations: local filesystem, S3, SFTP, WebDAV.
See [[Service-Lifecycle]] for how services implement these interfaces and [[Message-Bus]] for the message type interfaces.