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) -> OnDiskFingerprint
pub fn from_path_and_text(path: &Path, text: &str) -> OnDiskFingerprint
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: &OnDiskFingerprint) -> bool
pub fn same_content(&self, other: &OnDiskFingerprint) -> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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.§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
§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