pub struct DynamicRegistry { /* private fields */ }Expand description
In-memory index of every active dynamic registration for one
server actor. Empty on a fresh server; mutated by the actor on
client/(un)registerCapability and snapshotted into the
published Capabilities on every
change.
Two-way index (by_id + by_method) keeps both register
(O(1) append) and unregister (O(1) lookup by id) cheap, with
the “is method X registered?” probe also O(1) via the
per-method bucket.
Implementations§
Source§impl DynamicRegistry
impl DynamicRegistry
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct an empty registry. Used at handshake and whenever the actor restarts (each restart starts clean; the server replays its registrations).
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
True iff the registry has no entries. Cheap shortcut for the common steady-state case – most probes ask “is this dynamically registered?” and the registry is usually empty, so we want the false branch to be O(1).
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Number of distinct registrations currently active. Each
Registration from a RegistrationParams batch counts
once – duplicate ids (server error) are deduplicated by
Self::register.
Sourcepub fn register(&mut self, reg: DynamicRegistration)
pub fn register(&mut self, reg: DynamicRegistration)
Add one registration. If the id is already present, the
new entry replaces the old (servers shouldn’t reuse ids
without unregistering first, but if they do we honour
the latest). The by_method index is updated to remove
the stale entry from the old method’s bucket before
inserting under the new method.
Sourcepub fn unregister(&mut self, id: &str)
pub fn unregister(&mut self, id: &str)
Evict the registration matching id. Silently no-op when
the id is absent (server may unregister speculatively
after a restart; rejecting would just spam the log).
Sourcepub fn has(&self, method: &str) -> bool
pub fn has(&self, method: &str) -> bool
True iff at least one active registration targets the
given LSP method. The probe supports_* family calls
here to OR into their static ServerCapabilities check.
Sourcepub fn registrations_for<'a>(
&'a self,
method: &str,
) -> impl Iterator<Item = &'a DynamicRegistration> + 'a
pub fn registrations_for<'a>( &'a self, method: &str, ) -> impl Iterator<Item = &'a DynamicRegistration> + 'a
Borrow every registration for the given method in
insertion order. Used by feature consumers that need
the register_options blob – e.g. the file-watcher
pump (4.4.l) reads each DidChangeWatchedFilesRegistrationOptions
to know which glob patterns to subscribe to.
Sourcepub fn get(&self, id: &str) -> Option<&DynamicRegistration>
pub fn get(&self, id: &str) -> Option<&DynamicRegistration>
Borrow one registration by id. Used by tests and the
log surface (4.4.n’s :lsp-status extension will dump
every active dynamic registration for diagnosis).
Trait Implementations§
Source§impl Clone for DynamicRegistry
impl Clone for DynamicRegistry
Source§fn clone(&self) -> DynamicRegistry
fn clone(&self) -> DynamicRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DynamicRegistry
impl Debug for DynamicRegistry
Source§impl Default for DynamicRegistry
impl Default for DynamicRegistry
Source§fn default() -> DynamicRegistry
fn default() -> DynamicRegistry
Auto Trait Implementations§
impl Freeze for DynamicRegistry
impl RefUnwindSafe for DynamicRegistry
impl Send for DynamicRegistry
impl Sync for DynamicRegistry
impl Unpin for DynamicRegistry
impl UnsafeUnpin for DynamicRegistry
impl UnwindSafe for DynamicRegistry
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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