pub struct DiagnosticsCache { /* private fields */ }Expand description
Bounded per-session LRU cache for diagnostics pushed via lsp/publishDiagnostics.
Holds diagnostics for at most max_files files. When a new URI is inserted at
capacity, the least-recently-used file is evicted.
URI keys are compared as-is; normalization (case, symlinks) is the IDE’s responsibility.
§Examples
use zeph_acp::DiagnosticsCache;
let mut cache = DiagnosticsCache::new(10);
assert!(cache.is_empty());
assert!(cache.peek("file:///src/main.rs").is_none());Implementations§
Source§impl DiagnosticsCache
impl DiagnosticsCache
Sourcepub fn new(max_files: usize) -> Self
pub fn new(max_files: usize) -> Self
Create a new cache with the given file limit (minimum 1).
§Examples
use zeph_acp::DiagnosticsCache;
let cache = DiagnosticsCache::new(50);
assert!(cache.is_empty());Sourcepub fn update(&mut self, uri: String, diagnostics: Vec<LspDiagnostic>)
pub fn update(&mut self, uri: String, diagnostics: Vec<LspDiagnostic>)
Insert or replace diagnostics for a URI, evicting the oldest entry when at capacity.
Sourcepub fn peek(&self, uri: &str) -> Option<&[LspDiagnostic]>
pub fn peek(&self, uri: &str) -> Option<&[LspDiagnostic]>
Peek at diagnostics for a URI without refreshing LRU order.
Returns None if not cached. Reads do not affect eviction order — only
update() refreshes recency. Rename from get() to make peek semantics explicit.
Sourcepub fn all_non_empty(&self) -> Vec<(&str, &[LspDiagnostic])>
pub fn all_non_empty(&self) -> Vec<(&str, &[LspDiagnostic])>
Return all files that have at least one diagnostic.
Auto Trait Implementations§
impl Freeze for DiagnosticsCache
impl RefUnwindSafe for DiagnosticsCache
impl Send for DiagnosticsCache
impl Sync for DiagnosticsCache
impl Unpin for DiagnosticsCache
impl UnsafeUnpin for DiagnosticsCache
impl UnwindSafe for DiagnosticsCache
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
Converts
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>
Converts
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 moreSource§impl<T> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
fn into_option(self) -> Option<T>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request