Expand description
ModeRegistry: register modes, look them up, drive
activation / deactivation against a per-buffer ActiveModes
and an App-owned GuardStoreHandle.
M-async.3: activation is spawn-based with sequential
cascade. The sync prefix walks the requested mode + its
implies() tree, validates each, mutates active_modes for
each, and builds an ordered cascade plan
(Vec<CascadeStep>). One task is spawned that walks the
plan in DFS order, awaiting each step’s on_activate.await
before moving to the next. This guarantees a parent’s
lifecycle resolves before its implied children’s begin –
no sub-mode reads parent’s not-yet-written state.
On lifecycle error the spawned task publishes
ModeActivationFailed for the failing step, then publishes
ModeActivationFailed { reason: "cascade aborted by X" }
for every remaining (unrun) step. An App-side subscriber
(drain_mode_lifecycle_events) rolls back active_modes /
mode_guards on each.
Deactivation stays synchronous (Drop is sync): the
dispatcher locks the store, removes the Guard, drops it. The
MajorExiting / MinorDeactivated event publishes before
the drop fires.
Validation order before spawning:
- Mode is registered (
ModeActivationError::NotRegistered). - Mode kind matches the call (
WrongKind). - Buffer satisfies required capabilities
(
MissingCapability). - No conflict with already-active modes (
Conflict). - All
impliesdependencies are registered (UnregisteredDependency).
Lifecycle errors (from on_activate.await) become
ModeActivationFailed events on the bus; the spawned task
never returns them to the caller (the caller already
returned Ok(())).
Structs§
- Mode
Registry - Mode registry. Owns the catalogue of registered modes
(
Arc<dyn DynMode>) and drives activation / deactivation.
Enums§
- Registration
Error - Why a registration failed.
Type Aliases§
- Mode
Registry Handle - The runtime-mutable mode-registry handle the editor holds and shares as a
service.
ArcSwapgives wait-free reads on the keymap-resolution / mode-activation paths and copy-on-write RCU writes for runtime mode registration (a mode plugin loaded via:plugin-load, PL8.B). Reads take a snapshot (load/load_full); a mode load/unload clones-mutates-stores a fresh registry. The plugin loader reaches this viaservice::<ModeRegistryHandle>().