pub enum IndexState {
Building {
phase: IndexPhase,
indexed_count: usize,
total_count: usize,
started_at: Instant,
},
Ready {
symbol_count: usize,
file_count: usize,
completed_at: Instant,
},
Degraded {
reason: DegradationReason,
available_symbols: usize,
since: Instant,
},
}Expand description
Index readiness state - explicit lifecycle management
Represents the current operational state of the workspace index, enabling LSP handlers to provide appropriate responses based on index availability. This state machine prevents blocking operations and ensures graceful degradation when the index is not fully ready.
§State Transitions
Building→Ready: Workspace scan completes successfullyBuilding→Degraded: Scan timeout, IO error, or resource limitReady→Building: Workspace folder change or file watching eventsReady→Degraded: Parse storm (>10 pending) or IO errorDegraded→Building: Recovery attempt after cooldownDegraded→Ready: Successful re-scan after recovery
§Invariants
- During a single build attempt,
phaseadvances monotonically (Idle→Scanning→Indexing). indexed_countmust not exceedtotal_count; callers should keep totals updated.ReadyandDegradedcounts are snapshots captured at transition time.
§Usage
ⓘ
use perl_parser::workspace_index::{IndexPhase, IndexState};
use std::time::Instant;
let state = IndexState::Building {
phase: IndexPhase::Indexing,
indexed_count: 50,
total_count: 100,
started_at: Instant::now(),
};Variants§
Building
Index is being constructed (workspace scan in progress)
Fields
§
phase: IndexPhaseCurrent build phase (Idle → Scanning → Indexing)
Ready
Index is consistent and ready for queries
Fields
Degraded
Index is serving but degraded
Implementations§
Source§impl IndexState
impl IndexState
Sourcepub fn kind(&self) -> IndexStateKind
pub fn kind(&self) -> IndexStateKind
Return the coarse state kind for instrumentation and routing decisions
Sourcepub fn phase(&self) -> Option<IndexPhase>
pub fn phase(&self) -> Option<IndexPhase>
Return the current build phase when in Building state
Sourcepub fn state_started_at(&self) -> Instant
pub fn state_started_at(&self) -> Instant
Timestamp of when the current state began
Trait Implementations§
Source§impl Clone for IndexState
impl Clone for IndexState
Source§fn clone(&self) -> IndexState
fn clone(&self) -> IndexState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for IndexState
impl RefUnwindSafe for IndexState
impl Send for IndexState
impl Sync for IndexState
impl Unpin for IndexState
impl UnsafeUnpin for IndexState
impl UnwindSafe for IndexState
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