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
impl BufferLocals
Sourcepub fn insert<T: BufferLocal>(&mut self, value: T)
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.
Sourcepub fn get<T: BufferLocal>(&self) -> Option<&T>
pub fn get<T: BufferLocal>(&self) -> Option<&T>
Read the local of type T if present.
Sourcepub fn iter_descriptors(&self) -> impl Iterator<Item = LocalDescriptor> + '_
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.
Sourcepub fn contains<T: BufferLocal>(&self) -> bool
pub fn contains<T: BufferLocal>(&self) -> bool
True if a local of type T is currently stored.
Trait Implementations§
Source§impl Clone for BufferLocals
impl Clone for BufferLocals
Source§fn clone(&self) -> Self
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)
fn clone_from(&mut self, source: &Self)
source. Read more