pub struct ModeContext { /* private fields */ }Expand description
Lifecycle context. Carries the current activation’s metadata + cheap-clone handles to the system registries the mode may need.
Owned, Send + 'static: the dispatcher constructs one
per activation, moves it into the lifecycle future, and
drops it when the future resolves.
Implementations§
Source§impl ModeContext
impl ModeContext
Sourcepub fn new(
buffer_id: BufferId,
current_mode: ModeId,
config: Arc<ConfigRegistry>,
events: Arc<EventBus>,
services: Arc<ServiceRegistry>,
) -> Self
pub fn new( buffer_id: BufferId, current_mode: ModeId, config: Arc<ConfigRegistry>, events: Arc<EventBus>, services: Arc<ServiceRegistry>, ) -> Self
Construct a new context. Public for tests that drive mode lifecycle directly; production callers go through the registry’s activation methods which build the context internally.
Sourcepub fn service<T: Any + Send + Sync>(&self) -> Option<Arc<T>>
pub fn service<T: Any + Send + Sync>(&self) -> Option<Arc<T>>
Typed service lookup. Used by modes that need access to
subsystem handles (e.g. LspMode retrieves
LspSupervisorHandle; LspLogMode retrieves
BufferStoreHandle to synthesize its *lsp* buffer).
Returns None when no service of type T is registered
– modes should fail gracefully (log / echo) rather than
panic, since tests may run a mode without wiring the
service.
Sourcepub fn config(&self) -> &ConfigRegistry
pub fn config(&self) -> &ConfigRegistry
Shared typed-options registry. Mutations propagate
through the registry’s OptionChanged event stream the
same way :set does, so subscribers fire automatically.
Sourcepub fn config_handle(&self) -> Arc<ConfigRegistry> ⓘ
pub fn config_handle(&self) -> Arc<ConfigRegistry> ⓘ
Cheap-clone handle to the config registry. Use when the
mode needs to stash the registry inside its Guard for
later mutation (e.g. restoring an option in Drop).
Sourcepub fn events_handle(&self) -> Arc<EventBus> ⓘ
pub fn events_handle(&self) -> Arc<EventBus> ⓘ
Cheap-clone handle to the event bus. Use when the mode
needs to stash the bus inside its Guard for later
publish / unsubscribe (e.g. unsubscribing a subscription
ID in Drop).
Sourcepub fn current_mode(&self) -> ModeId
pub fn current_mode(&self) -> ModeId
The mode whose lifecycle hook is currently running.