pub struct OnDiskFingerprint {
pub mtime: Option<SystemTime>,
pub size: u64,
pub content_hash: u64,
}Expand description
The on-disk identity of a file-backed buffer at the moment the editor
last synced with disk — a load, or its own :w.
Two comparison surfaces, deliberately distinct:
Self::same_content(content hash) is the authoritative “is this the same file we already have” test. Atouchthat bumps mtime without changing bytes must compare equal, so mtime/size are not part of it.Self::stat_unchangedis the cheap(mtime, size)pre-gate the watcher uses to decide whether it even needs to read + hash the file.
Fields§
§mtime: Option<SystemTime>Last-modified time from stat, or None on platforms / filesystems
where it’s unavailable (then detection leans on content_hash alone).
size: u64Byte length from stat (0 when metadata is unavailable).
content_hash: u64Hash of the text the editor holds for this file — the precise check that survives mtime-only touches and identifies self-writes.
Implementations§
Source§impl OnDiskFingerprint
impl OnDiskFingerprint
Sourcepub fn from_path_and_text(path: &Path, text: &str) -> Self
pub fn from_path_and_text(path: &Path, text: &str) -> Self
Build a fingerprint from path’s current metadata plus the text
the editor holds for it. stat failure degrades to
mtime = None / size = 0 rather than erroring — a missing stat
must never break a load or a save (paramount: never panic on the
hot path; recover + lean on the content hash).
Sourcepub fn same_content(&self, other: &Self) -> bool
pub fn same_content(&self, other: &Self) -> bool
True when self and other denote the same on-disk content.
Content hash is authoritative; mtime/size are ignored so a bare
touch is correctly treated as “no change”.
Sourcepub fn stat_unchanged(&self, path: &Path) -> bool
pub fn stat_unchanged(&self, path: &Path) -> bool
Cheap pre-gate: true when path’s current (mtime, size) still
match this fingerprint, i.e. the file almost certainly hasn’t
changed and the watcher can skip the read + hash entirely. A stat
failure returns false (fall through to the authoritative read),
as does a None stored mtime (we never had a baseline to gate on).
Trait Implementations§
Source§impl Clone for OnDiskFingerprint
impl Clone for OnDiskFingerprint
Source§fn clone(&self) -> OnDiskFingerprint
fn clone(&self) -> OnDiskFingerprint
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 OnDiskFingerprint
impl Debug for OnDiskFingerprint
impl Eq for OnDiskFingerprint
Source§impl PartialEq for OnDiskFingerprint
impl PartialEq for OnDiskFingerprint
impl StructuralPartialEq for OnDiskFingerprint
Auto Trait Implementations§
impl Freeze for OnDiskFingerprint
impl RefUnwindSafe for OnDiskFingerprint
impl Send for OnDiskFingerprint
impl Sync for OnDiskFingerprint
impl Unpin for OnDiskFingerprint
impl UnsafeUnpin for OnDiskFingerprint
impl UnwindSafe for OnDiskFingerprint
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.