pub struct FixityCache { /* private fields */ }Expand description
What this device remembers of a workspace’s file digests.
Keyed by workspace-relative path, so a workspace that moves keeps its
cache; root is recorded only to refuse a cache that was written for a
different workspace entirely.
Implementations§
Source§impl FixityCache
impl FixityCache
Sourcepub fn decode(bytes: &[u8], root: &Path) -> Option<Self>
pub fn decode(bytes: &[u8], root: &Path) -> Option<Self>
Decode what was persisted for the workspace at root.
None for anything that is not exactly what some build of prov wrote
for this workspace — the caller’s move is to start
new, never to investigate.
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
The bytes to persist. Pair with is_dirty: a cache
that learned nothing this run is worth writing to nobody.
Sourcepub fn get(&self, path: &Path, meta: &Metadata) -> Option<&str>
pub fn get(&self, path: &Path, meta: &Metadata) -> Option<&str>
The remembered digest for the workspace-relative path, if the file
meta describes is still the one it was recorded against.
Both halves of the stat must agree: a length alone misses an edit that preserved the size, and a timestamp alone trusts a clock the file may have arrived with.
Sourcepub fn put(&mut self, path: &Path, meta: &Metadata, hash: &str)
pub fn put(&mut self, path: &Path, meta: &Metadata, hash: &str)
Remember that path hashed to hash at the stat meta describes.
Three things are declined rather than stored wrong: a file whose backend
reports no modification time (nothing could ever validate it, so keeping
it would only cost space), a path that is not valid UTF-8 (it has no
stable key, and a lossy one could collide with a different file), and
anything at all once [MAX_ENTRIES] is reached.
Trait Implementations§
Source§impl Clone for FixityCache
impl Clone for FixityCache
Source§fn clone(&self) -> FixityCache
fn clone(&self) -> FixityCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more