pub struct FileSnapshot { /* private fields */ }Expand description
A pre-operation snapshot that can prove whether a file’s contents changed.
Most filesystems provide a stable metadata-change token, so the inexpensive identity is sufficient. Linux NFS can reconcile client and server timestamps after a writer has closed the file, making two metadata reads disagree without any intervening write. Those files carry a content digest instead, while retaining length and file identity to detect replacement. Callers use the same comparison either way and do not need to know which filesystem supplied the file.
Implementations§
Source§impl FileSnapshot
impl FileSnapshot
Sourcepub fn capture(path: &Path) -> Result<Option<Self>>
pub fn capture(path: &Path) -> Result<Option<Self>>
Capture the strongest comparison the file’s filesystem can support.
Sourcepub fn capture_with_cache(
path: &Path,
digests: &dyn FileDigestCache,
) -> Result<Option<Self>>
pub fn capture_with_cache( path: &Path, digests: &dyn FileDigestCache, ) -> Result<Option<Self>>
Capture a snapshot while reusing or publishing a content digest through the session ledger when the filesystem requires one.
Sourcepub fn matches(
&self,
identity: Option<&FileIdentity>,
content: &CacheDigest,
) -> bool
pub fn matches( &self, identity: Option<&FileIdentity>, content: &CacheDigest, ) -> bool
Whether identity and content still describe this snapshot.
A content-backed snapshot ignores both timestamps: NFS can reconcile mtime as well as ctime without a content change. Matching endpoint digests cannot detect an intervening edit that restores the original bytes. Digest-cache lookup still uses timestamps to decide when a digest needs refreshing; this comparison performs no additional reads.
Sourcepub fn proves_content_change(&self) -> bool
pub fn proves_content_change(&self) -> bool
Whether a mismatch proves the file’s contents changed.
Trait Implementations§
Source§impl Clone for FileSnapshot
impl Clone for FileSnapshot
Source§fn clone(&self) -> FileSnapshot
fn clone(&self) -> FileSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more