pub struct AccessLedger { /* private fields */ }Expand description
An append-only log of split accesses.
Implementations§
Source§impl AccessLedger
impl AccessLedger
Sourcepub fn record(
&mut self,
role: &str,
profile: &str,
purpose: &str,
fingerprint_hex: &str,
)
pub fn record( &mut self, role: &str, profile: &str, purpose: &str, fingerprint_hex: &str, )
Append one access. There is no removal API: an append-only log that can be rewritten is not evidence.
Sourcepub fn records(&self) -> &[AccessRecord]
pub fn records(&self) -> &[AccessRecord]
The recorded accesses, in call order.
Sourcepub fn to_canonical_bytes(&self) -> Result<Vec<u8>, ContrastiveDataError>
pub fn to_canonical_bytes(&self) -> Result<Vec<u8>, ContrastiveDataError>
Deterministic canonical serialization — the artifact a later phase’s selection lock reads.
Compact JSON over a struct with a fixed field order and a Vec whose order IS the
access order. There is no map to iterate and no timestamp to drift, so two runs
that touched the same splits in the same order produce byte-identical output.
§Errors
ContrastiveDataError::Serialization if the ledger cannot be serialized.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, ContrastiveDataError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, ContrastiveDataError>
Parse a canonical ledger.
§Errors
ContrastiveDataError::Serialization on malformed bytes, or
ContrastiveDataError::UnsupportedSchemaVersion on a future schema.
Sourcepub fn ledger_hash(&self) -> [u8; 32]
pub fn ledger_hash(&self) -> [u8; 32]
SHA-256 of Self::to_canonical_bytes.
Total rather than fallible: the canonical form is a u32 and a vector of structs
of Strings, which has no non-string map key and no non-finite float, so
serde_json has no failure mode to report. The expect documents that reasoning
at the one place it is relied upon rather than pushing a Result into every
caller that only ever wants a digest.