MingaEditor.Shell.Registry.Snapshot (Minga v0.1.0)

Copy Markdown View Source

Pure coherent publication value for the serialized shell registry.

Summary

Functions

Advances the coherent publication generation.

Returns the entry registered for an implementation module.

Builds an unpublished snapshot from validated entries.

Builds an empty unpublished snapshot.

Adds or refreshes a built-in contribution while preserving stable identity.

Registers a new contribution after coherent duplicate checks.

Resolves a shell id or implementation module from this publication.

Removes one contribution only when the source owns it.

Removes every contribution owned by one source in one value transition.

Types

register_error()

@type register_error() ::
  {:duplicate_id, shell_id()}
  | {:duplicate_module, module(), shell_id()}
  | {:duplicate_default, shell_id()}

shell_id()

@type shell_id() :: atom()

t()

@type t() :: %MingaEditor.Shell.Registry.Snapshot{
  default_id: shell_id() | nil,
  entries: %{optional(shell_id()) => MingaEditor.Shell.Entry.t()},
  generation: non_neg_integer(),
  next_generation: pos_integer(),
  ordered: [MingaEditor.Shell.Entry.t()]
}

Functions

advance(snapshot)

@spec advance(t()) :: t()

Advances the coherent publication generation.

entry_for_module(snapshot, module)

@spec entry_for_module(t(), module()) :: MingaEditor.Shell.Entry.t() | nil

Returns the entry registered for an implementation module.

from_entries(entries)

@spec from_entries([MingaEditor.Shell.Entry.t()]) :: t()

Builds an unpublished snapshot from validated entries.

new()

@spec new() :: t()

Builds an empty unpublished snapshot.

put_builtin(snapshot, entry)

@spec put_builtin(t(), MingaEditor.Shell.Entry.t()) ::
  {:ok, t()} | {:error, register_error()}

Adds or refreshes a built-in contribution while preserving stable identity.

register(snapshot, entry)

@spec register(t(), MingaEditor.Shell.Entry.t()) ::
  {:ok, t()} | {:error, register_error()}

Registers a new contribution after coherent duplicate checks.

resolve(snapshot, id_or_module)

@spec resolve(t(), shell_id() | module()) :: MingaEditor.Shell.Entry.t() | nil

Resolves a shell id or implementation module from this publication.

unregister(snapshot, source, id)

@spec unregister(t(), MingaEditor.Shell.Entry.source(), shell_id()) ::
  {:ok, t(), boolean()} | {:error, :not_owner}

Removes one contribution only when the source owns it.

unregister_source(snapshot, source)

@spec unregister_source(t(), MingaEditor.Shell.Entry.source()) :: {t(), boolean()}

Removes every contribution owned by one source in one value transition.