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.
§Two shapes in one type
Every record this code seals is schema version 2 and carries its
event and the event’s payload schema version. Both are Option for
one reason: records written under schema version 1 — the journals
of stores from v0.3.0 and earlier — carry no payload, and they must
keep deserializing and verifying exactly as they did until the
copy-on-write migration imports them. A version-1 record therefore
has neither; a version-2 record without its event is not intact.
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.
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.
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.
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.
Trait Implementations§
Source§impl Clone for AuditRecord
impl Clone for AuditRecord
Source§fn clone(&self) -> AuditRecord
fn clone(&self) -> AuditRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more