Skip to main content

BufferLocals

Struct BufferLocals 

Source
pub struct BufferLocals { /* private fields */ }
Expand description

Typed-map of buffer-local mode-internal state.

Stored on per-buffer host state, one map per buffer. The host writes entries (seeding at buffer construction, or on a mode’s behalf — e.g. ModeActivator::set_buffer_scope_dir); anyone reads via Self::get. Removal is pub(crate) and not yet wired to any caller.

Implementations§

Source§

impl BufferLocals

Source

pub fn new() -> Self

An empty map.

Source

pub fn len(&self) -> usize

Number of locals stored.

Source

pub fn is_empty(&self) -> bool

True when no local is stored.

Source

pub fn insert<T: BufferLocal>(&mut self, value: T)

Insert (or replace) the local of type T. Public so the App can seed locals at buffer-construction time (e.g. help-mode parsing the markdown links into HelpLinks when a help buffer is constructed – the “owner” semantically is help-mode, but the App is the caller because parsing lives in the constructor).

The owner-mode check is intentionally NOT enforced here; the design gives that job to a checked ModeContext::set_local for active modes’ runtime writes, which does not exist yet. App-level construction-time seeding is a separate path: the App is presumed to insert locals owned by the buffer’s eventual major mode, and the local’s OWNER_MODE field is metadata for :describe-buffer attribution rather than an access-control mechanism on this surface. Mirrors emacs’s setq-local – any code can set a buffer-local; the major mode’s claim of ownership is by convention.

Source

pub fn get<T: BufferLocal>(&self) -> Option<&T>

Read the local of type T if present.

Source

pub fn iter_descriptors(&self) -> impl Iterator<Item = LocalDescriptor> + '_

Iterate over descriptors for inspection. Walks every local with its display metadata + a single-line summary. Used by :describe-buffer to enumerate all state on a buffer grouped by owner mode.

Source

pub fn contains<T: BufferLocal>(&self) -> bool

True if a local of type T is currently stored.

Trait Implementations§

Source§

impl Clone for BufferLocals

Source§

fn clone(&self) -> Self

Slice 3c.final.B.9: walks the typed-map and clone_box’s each entry so the whole BufferLocals can be deep-cloned for BufferLocalsRenderState publishes.

1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BufferLocals

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BufferLocals

Source§

fn default() -> BufferLocals

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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