pub struct CacheKeyBuilder { /* private fields */ }Expand description
Driver for cache-key derivation.
Construct with CacheKeyBuilder::new (which carries the
active HashAlgo and writes the schema-version prefix per
CACHE-003), then call CacheKeyBuilder::finish to consume
the canonical CacheKeyInputs and emit a CacheKey.
One builder produces one key; the type is not reusable. To derive several keys, construct a fresh builder per key. The canonical-byte sequence depends on the prefix being the very first contribution; the new-builder/finish pairing makes this invariant structural.
Implementations§
Source§impl CacheKeyBuilder
impl CacheKeyBuilder
Sourcepub fn new(algo: HashAlgo) -> Self
pub fn new(algo: HashAlgo) -> Self
Construct a fresh builder under algo.
The schema-version prefix (CACHE-003) is written into the
hasher immediately: [CHAPTER_REVISION, hash_function_id].
Any later finish call therefore derives a key under the
composite of (chapter_revision, hash_function_id) for that
algo, even when no other component is supplied.
Sourcepub fn finish(self, inputs: &CacheKeyInputs<'_>) -> CacheKey
pub fn finish(self, inputs: &CacheKeyInputs<'_>) -> CacheKey
Consume the builder, contribute every CACHE-004 component
in canonical order (CACHE-009), and return the finalised
CacheKey.