Logo FSBarV1_Archived

HubSettings Module

Hub-wide user-editable settings. Persisted as a single JSON document under the XDG config home. **Phase 2 scope note**: the planning sketch included a `LastLobby` field of type `LobbyConfig option` for persisting the user's most recent lobby. That field is deferred to Phase 3 (task T027, when `LobbyConfig` lands); the current JSON schema reserves room for it via a forward-compatible `SchemaVersion` field but does not yet emit / consume it.

Types

Type Description

HubSettings

JSON-serialisable record. All fields are required on write; missing fields on read are filled from `defaults`.

Functions and values

Function or value Description

defaults

Full Usage: defaults

Returns: HubSettings

Factory values identical to a fresh-install state: no overrides, port `5021`, graphical-viewer toggle off, start-paused toggle on, 8 concurrent render subscribers, 8 concurrent log-stream subscribers, schema `3`.

Returns: HubSettings

load ()

Full Usage: load ()

Parameters:
    () : unit

Returns: HubSettings
 Loads settings from `settingsPath ()`.

 Behaviour:
   * File absent → `defaults`.
   * Parse error or missing required field → `defaults` with a
     diagnostic written to stderr. Never raises on malformed JSON.
   * `GrpcPort` outside `[1024, 65535]` → the field is clamped to
     `defaults.GrpcPort`; other fields are preserved.
() : unit
Returns: HubSettings

save settings

Full Usage: save settings

Parameters:
Returns: Result<unit, string>

Atomically writes `settings` to `settingsPath ()`. The write is temp-file-plus-rename to prevent torn reads: serialises to a sibling `*.tmp` file, flushes, then renames over the target. Returns `Ok ()` on success; `Error msg` carries an operator-visible reason on failure (permissions, I/O error, serialisation).

settings : HubSettings
Returns: Result<unit, string>

settingsPath ()

Full Usage: settingsPath ()

Parameters:
    () : unit

Returns: string

Returns the absolute filesystem path where settings are read / written. Resolves in this order: `$XDG_CONFIG_HOME/fsbar-hub/settings.json` when the variable is set and non-empty; otherwise `$HOME/.config/fsbar-hub/settings.json`.

() : unit
Returns: string

updateLaunchGraphicalViewerDefault settings value

Full Usage: updateLaunchGraphicalViewerDefault settings value

Parameters:
Returns: HubSettings

Return a copy of `settings` with `LaunchGraphicalViewerDefault = value`. Pure transformation.

settings : HubSettings
value : bool
Returns: HubSettings

updateMaxLogStreamSubscribers settings value

Full Usage: updateMaxLogStreamSubscribers settings value

Parameters:
Returns: Result<HubSettings, string>

Return a validated copy of `settings` with `MaxLogStreamSubscribers = value`. Rejects values outside `[1, 32]` with an operator-visible reason (feature 042 R7).

settings : HubSettings
value : int
Returns: Result<HubSettings, string>

updateMaxRenderFrameSubscribers settings value

Full Usage: updateMaxRenderFrameSubscribers settings value

Parameters:
Returns: Result<HubSettings, string>

Return a validated copy of `settings` with `MaxRenderFrameSubscribers = value`. Rejects values outside `[1, 32]` with an operator-visible reason (data-model §HubSettings).

settings : HubSettings
value : int
Returns: Result<HubSettings, string>

updateStartPausedDefault settings value

Full Usage: updateStartPausedDefault settings value

Parameters:
Returns: HubSettings

Return a copy of `settings` with `StartPausedDefault = value`. Pure transformation; callers persist via `save` and publish a `HubEvent.HubSettingsChanged` if desired.

settings : HubSettings
value : bool
Returns: HubSettings

Type something to start searching.