Expand description
§libvctrl_core
Reference implementations for the contracts defined by
libvctrl_handler.
This crate provides production-ready, safe implementations of hashing,
binary serialization, in-memory storage, reference management, and builder
utilities. It is the first concrete consumer of the libvctrl_handler
traits and serves as a quality exemplar for downstream custom backends.
§Architecture
The crate is organized by domain responsibility:
codec— deterministic binary encoding and decoding.hash— SHA-512 content addressing.object— ergonomic builder patterns.store— in-memory object and reference stores.
Each module depends only on the public contracts exposed by
libvctrl_handler, plus the SHA-512 implementation from
libvctrl_sha512. No module contains unsafe code.
§Safety and quality
The crate forbids unsafe code and denies a strict set of Clippy and rustc lints. Every public item is documented and has doctests where applicable. The binary decoder is especially defensive: it bounds all input reads, verifies version bytes, validates UTF-8, and re-checks system limits before constructing any object.
§Example
A common workflow encodes an object, hashes it, stores it, and retrieves it through the in-memory store:
let blob = Blob::new(b"my content".to_vec()).unwrap();
let mut encoded = Vec::new();
BinaryEncoder.encode_blob(&blob, &mut encoded).unwrap();
let hash = Sha512Hasher.hash(&mut encoded.as_slice()).unwrap();
let mut store = MemoryStore::new();
store.put(&hash, &encoded).unwrap();
let mut reader = store.get(&hash).unwrap();
let mut decoded = Vec::new();
reader.read_to_end(&mut decoded).unwrap();
assert_eq!(decoded, encoded);