pub struct DocumentState { /* private fields */ }Expand description
State of a single document.
All fields are private. DocumentTracker::open (via Self::new)
establishes the initial state: version starts at 1, disk provenance
starts None, and no server is recorded as synced. From there, every
mutation goes through a dedicated method (apply_local_edit,
commit_reload, set_disk, mark_synced, forget_server) rather than a
partial field write, so within a single tracked lifetime version (see
Self::version) only increases. This does not cover re-opening: calling
DocumentTracker::open again for an already-tracked path unconditionally
replaces the entry, resetting version to 1 and clearing synced – see
that method’s docs.
The disk provenance invariant: None means the content’s on-disk
provenance is unknown (it came from an in-memory open/update call, not
a verified disk read), so ensure_open must always re-verify by content
compare rather than trusting a stat match. DiskSync’s hand-written
PartialEq excludes content_checked_at (see that field’s doc comment),
and that exclusion propagates here: two DocumentStates can compare
equal via this struct’s derived PartialEq/Eq despite having been
disk-verified at different instants. This is intentional –
content_checked_at is a debounce timer, not part of a document’s
logical state.
Implementations§
Source§impl DocumentState
impl DocumentState
Sourcepub fn language_id(&self) -> &str
pub fn language_id(&self) -> &str
Language identifier.
Sourcepub const fn version(&self) -> i32
pub const fn version(&self) -> i32
Document version. Monotonically increasing: every mutation that
changes content (apply_local_edit, commit_reload) also bumps
this, and never decreases it.
Sourcepub fn synced_version(&self, server: &ServerId) -> Option<i32>
pub fn synced_version(&self, server: &ServerId) -> Option<i32>
Last document version pushed to server via didOpen/didChange,
or None if server has never seen this document.
A single document can be synced to multiple servers (e.g. hover
routed to one server, diagnostics to another for the same language),
each needing its own didOpen/didChange history – a server absent
from this map has never seen the document and must receive
didOpen, not didChange, on its next ensure_open call.
Trait Implementations§
Source§impl Clone for DocumentState
impl Clone for DocumentState
Source§fn clone(&self) -> DocumentState
fn clone(&self) -> DocumentState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more