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 the client and server change times 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 modification time as an independent signal for a write that restored the original bytes. 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 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 deliberately ignores the unreliable change token, but still requires the modification time to remain stable. That prevents a write followed by restoration of the original bytes from passing only because the endpoint digests agree.
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