mbx-cache-core 0.4.0

Action cache protocol, CAS, authentication, and transport primitives for mbx
Documentation

Protocol and storage primitives for mbx build caches.

This crate contains the types shared by cache clients, the task-scoped cache agent, and remote cache implementations. Protocol records are serialized with [canonical_json] before hashing; changing their shape is therefore a wire-format change, not merely an implementation detail.

Most consumers start with [CacheDigest] and the local stores [LocalCas] and [LocalActionCache]. Remote clients use [RemoteCacheClient], while mbx's compiler shim communicates with a [CacheAgent] using [AgentRequest] and [AgentResponse].

use mbx_cache_core::{CacheDigest, canonical_json};
use serde::Serialize;

#[derive(Serialize)]
struct Key<'a> {
    compiler: &'a str,
    source: CacheDigest,
}

let source = CacheDigest::blake3(b"fn main() {}\n");
let bytes = canonical_json(&Key { compiler: "rustc", source })?;
let action = CacheDigest::blake3(&bytes);
assert_eq!(action.algorithm, "blake3");
# Ok::<(), eyre::Report>(())