pub struct BufferStates<S> { /* private fields */ }Expand description
Per-buffer state for one magit mode.
One instance per state type, registered as a service at install
time. Entries are published by on_activate and removed when the
buffer’s mode guard drops, so a stale entry cannot outlive its
buffer.
Implementations§
Source§impl<S> BufferStates<S>
impl<S> BufferStates<S>
Sourcepub fn publish(&self, buffer: BufferId, state: S) -> Arc<Mutex<S>> ⓘ
pub fn publish(&self, buffer: BufferId, state: S) -> Arc<Mutex<S>> ⓘ
Publish state for buffer, replacing any prior entry (a
re-activation on the same buffer supersedes the old state).
Returns the shared handle so the caller can keep mutating it
after an await — see the module note on late-resolved fields.
Publish an already-shared state handle.
The peer of Self::publish for a mode that already owns an
Arc<Mutex<S>> (magit-status builds one for its fold source
before publishing).
Sourcepub fn get(&self, buffer: BufferId) -> Option<Arc<Mutex<S>>>
pub fn get(&self, buffer: BufferId) -> Option<Arc<Mutex<S>>>
The state for buffer, or None when no magit mode of this
type is live on it. Handlers treat None as “not mine” and
no-op — the same outcome as before, minus the race.
pub fn remove(&self, buffer: BufferId)
Sourcepub fn all(&self) -> Vec<Arc<Mutex<S>>>
pub fn all(&self) -> Vec<Arc<Mutex<S>>>
Every live state of this type, in no particular order.
MG.21c: for handlers that must reach their mode’s buffers
without being able to name one. A prompt’s -finish action
fires with the PROMPT buffer’s buffer_id (see
Editor::do_prompt_line_submit), so Self::get and
state_for both return None there — but the work it just
did still has to show up. Services are reachable from any
context, so the finish handler refreshes through this instead.
Trait Implementations§
Auto Trait Implementations§
impl<S> !Freeze for BufferStates<S>
impl<S> RefUnwindSafe for BufferStates<S>
impl<S> Send for BufferStates<S>where
S: Send,
impl<S> Sync for BufferStates<S>where
S: Send,
impl<S> Unpin for BufferStates<S>
impl<S> UnsafeUnpin for BufferStates<S>
impl<S> UnwindSafe for BufferStates<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more