diff --git a/Interfaces.md b/Interfaces.md new file mode 100644 index 0000000..84a94cb --- /dev/null +++ b/Interfaces.md @@ -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.