Skip to main content

PackDeltaCache

Trait PackDeltaCache 

Source
pub trait PackDeltaCache {
    // Required methods
    fn get(&self, offset: u64) -> Option<Arc<EncodedObject>>;
    fn insert(&self, offset: u64, object: Arc<EncodedObject>);
}
Expand description

A cache of objects already decoded from one specific pack, keyed by the in-pack byte offset at which each object’s entry begins.

Delta resolution within a pack walks a chain of base objects by offset; the same base is the parent of many deltas, so without a cache the entire chain is re-inflated and re-applied on every read. Implementors let [read_object_at_with_cache] reuse a warm base instead.

Correctness contract: a given offset within a given pack’s bytes always decodes to exactly one object, so caching by offset can never serve the wrong object provided the same cache is only ever used with one pack’s bytes. Callers must therefore scope a cache to a single pack (e.g. key it by pack path). The default [read_object_at] uses a no-op cache and is unaffected.

Required Methods§

Source

fn get(&self, offset: u64) -> Option<Arc<EncodedObject>>

Return the decoded object whose entry begins at offset, if cached.

Source

fn insert(&self, offset: u64, object: Arc<EncodedObject>)

Record that the entry beginning at offset decodes to object.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§