Skip to main content

ModeContext

Struct ModeContext 

Source
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

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub fn events(&self) -> &EventBus

Shared typed event bus.

Source

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).

Source

pub fn buffer_id(&self) -> BufferId

Buffer the activation is operating on.

Source

pub fn current_mode(&self) -> ModeId

The mode whose lifecycle hook is currently running.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more