Skip to main content

MultibufferRegistry

Trait MultibufferRegistry 

Source
pub trait MultibufferRegistry:
    Send
    + Sync
    + Debug {
    // Required methods
    fn handle(&self, view: BufferId) -> Option<Arc<MultibufferDocumentHandle>>;
    fn insert(&self, view: BufferId, handle: Arc<MultibufferDocumentHandle>);
    fn remove(&self, view: BufferId);
    fn remove_by_document_id(&self, document_id: DocumentId) -> bool;
    fn len(&self) -> usize;
    fn view_ids(&self) -> Vec<BufferId>;
}
Expand description

Typed handle lookup for active multibuffer views, keyed by the view buffer’s BufferId. Registered as a service in ServiceRegistry at boot.

Required Methods§

Source

fn handle(&self, view: BufferId) -> Option<Arc<MultibufferDocumentHandle>>

Return the typed handle for view if registered, else None. Cheap-clone: Arc::clone.

Source

fn insert(&self, view: BufferId, handle: Arc<MultibufferDocumentHandle>)

Register handle against view. Called by create_multibuffer_view after the handle is built. Overwrites if the view id already had a handle (last-write- wins; production code allocates fresh ids per view so a collision is a developer bug, not a hot-swap).

Source

fn remove(&self, view: BufferId)

Remove the entry for view. Idempotent: removing a non-existent entry is a no-op.

Source

fn remove_by_document_id(&self, document_id: DocumentId) -> bool

Remove the entry whose handle reports document_id as its MultibufferDocumentHandle::document_id. Called by the DocumentClosed subscriber (the event payload carries DocumentId, not BufferId). Returns true if an entry was removed. O(n) over active views; multibuffer counts are small so the walk is fine.

Source

fn len(&self) -> usize

Count of currently-registered views. Test-friendly probe.

Source

fn view_ids(&self) -> Vec<BufferId>

OA.23b: every registered view id.

What lets a bare SOURCE id be resolved back to the view that owns it. A source is not a buffer the user opened — the store has never heard of it (see MultibufferExcerptSource) — so the only way to find its document is to ask the views. View counts are small; the walk is fine.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§