Skip to main content

AuditRecord

Struct AuditRecord 

Source
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

Source

pub fn first(fact: AuditFact) -> Result<Self, DomainError>

Seal a fact as the first record of a ceremony’s journal.

Source

pub fn first_authorized(fact: AuthorizedAuditFact) -> Result<Self, DomainError>

Seal an authorized fact as the first record of a ceremony’s journal.

Source

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.

Source

pub fn following_authorized( fact: AuthorizedAuditFact, previous: &Self, ) -> Result<Self, DomainError>

Seal an authorized fact after a verified predecessor.

Source

pub fn event_id(&self) -> &EventId

Source

pub fn event_type(&self) -> AuditEventType

Source

pub fn schema_version(&self) -> u32

Source

pub fn ceremony_id(&self) -> &CeremonyId

Source

pub fn definition_name(&self) -> &CeremonyName

Source

pub fn definition_version(&self) -> &CeremonyVersion

Source

pub fn sequence(&self) -> AuditSequence

Source

pub fn occurred_at(&self) -> OffsetDateTime

Source

pub fn actor(&self) -> &AuditActor

Source

pub fn correlation_id(&self) -> Option<&EventId>

Source

pub fn causation_id(&self) -> Option<&EventId>

Source

pub fn trace_id(&self) -> Option<&str>

Source

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.

Source

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.

Source

pub fn authorization_evidence(&self) -> Option<&AuthorizationEvidence>

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.

Source

pub fn previous_record_hash(&self) -> Option<AuditRecordHash>

Source

pub fn record_hash(&self) -> AuditRecordHash

Source

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.

Source

pub fn continues(&self, previous: &Self) -> bool

Whether this record legitimately continues previous.

Checks the three ways a chain breaks at a join: the wrong ceremony, a position that is not the immediate successor, and a previous digest that does not match the record it names.

Trait Implementations§

Source§

impl Clone for AuditRecord

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AuditRecord

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AuditRecord

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for AuditRecord

Source§

impl PartialEq for AuditRecord

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for AuditRecord

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AuditRecord

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.