pub struct AuditRecord { /* private fields */ }Expand description
One fact in a ceremony’s audit journal.
Immutable by construction: the digest is computed once, from the content and the previous record’s digest, and every accessor is read-only. There is no setter that could leave the digest stale.
§Three shapes in one type
Version 1 is the historical flat envelope without an event. Version 2 is
the historical flat envelope carrying an event. Version 3 is an explicit
envelope carrying both the event and mandatory authorization evidence.
The optional fields keep all three generations readable in one domain
type; Self::has_canonical_shape rejects every contradictory mixture.
Implementations§
Source§impl AuditRecord
impl AuditRecord
Sourcepub fn first(fact: AuditFact) -> Result<Self, DomainError>
pub fn first(fact: AuditFact) -> Result<Self, DomainError>
Seal a fact as the first record of a ceremony’s journal.
Seal an authorized fact as the first record of a ceremony’s journal.
Sourcepub fn following(fact: AuditFact, previous: &Self) -> Result<Self, DomainError>
pub fn following(fact: AuditFact, previous: &Self) -> Result<Self, DomainError>
Seal a fact as the record that follows previous.
The successor’s position and previous digest are taken from the predecessor rather than supplied, so a caller cannot append a record that claims to follow something it does not.
Seal an authorized fact after a verified predecessor.
pub fn event_id(&self) -> &EventId
pub fn event_type(&self) -> AuditEventType
pub fn schema_version(&self) -> u32
pub fn ceremony_id(&self) -> &CeremonyId
pub fn definition_name(&self) -> &CeremonyName
pub fn definition_version(&self) -> &CeremonyVersion
pub fn sequence(&self) -> AuditSequence
pub fn occurred_at(&self) -> OffsetDateTime
pub fn actor(&self) -> &AuditActor
pub fn correlation_id(&self) -> Option<&EventId>
pub fn causation_id(&self) -> Option<&EventId>
pub fn trace_id(&self) -> Option<&str>
Sourcepub fn event_schema_version(&self) -> Option<EventSchemaVersion>
pub fn event_schema_version(&self) -> Option<EventSchemaVersion>
The shape the sealed event’s payload was written in.
Absent only on records sealed under schema version 1.
Sourcepub fn event(&self) -> Option<&CeremonyEvent>
pub fn event(&self) -> Option<&CeremonyEvent>
The event this record seals, payload included.
Absent only on records sealed under schema version 1, which recorded that something happened and not what.
The allow decision that admitted this mutation.
Present exactly on schema-version-3 records. Its absence on historical records is history, not an implicit authorization decision.
pub fn previous_record_hash(&self) -> Option<AuditRecordHash>
pub fn record_hash(&self) -> AuditRecordHash
Sourcepub fn digest_is_intact(&self) -> Result<bool, DomainError>
pub fn digest_is_intact(&self) -> Result<bool, DomainError>
Whether the digest still matches the content.
A record that fails this was altered after it was sealed, or was never sealed by this implementation — which includes a version-2 record that has lost its event, and a version-1 record that has gained one.