pub struct JournalEvent { /* private fields */ }Expand description
One committed, self-validating record in a run’s append-only journal.
digest is a domain-separated SHA-256 checksum over stable event metadata,
the full intent checksum, payload checksum, and previous event checksum. It
detects accidental corruption, omission, and reordering; an unkeyed hash
chain is not proof against a privileged actor able to rewrite every record.
Implementations§
Source§impl JournalEvent
impl JournalEvent
Sourcepub fn restore(
intent: JournalEventIntent,
sequence: JournalSequence,
recorded_at: Timestamp,
previous_digest: Option<Digest>,
digest: Digest,
) -> Result<Self, JournalEventError>
pub fn restore( intent: JournalEventIntent, sequence: JournalSequence, recorded_at: Timestamp, previous_digest: Option<Digest>, digest: Digest, ) -> Result<Self, JournalEventError>
Restores and verifies an event from durable storage columns.
The intent reconstructs and validates tenant, run, event identity, source, payload, payload checksum, and intent checksum. This method then validates sequence/predecessor shape and recomputes the complete event checksum before returning a usable event.
A store that persists redundant payload or intent digest columns must
compare those columns with intent before calling this method.
§Errors
Returns JournalEventError when the sequence/predecessor shape or
complete event checksum does not match the reconstructed event.
Sourcepub fn commit(
append: JournalAppend,
recorded_at: Timestamp,
) -> Result<Self, JournalEventError>
pub fn commit( append: JournalAppend, recorded_at: Timestamp, ) -> Result<Self, JournalEventError>
Materializes a validated append after the store has won its transaction.
recorded_at must be the database observation selected while holding the
current run row. For a non-empty journal it cannot precede the prior head;
a store may clamp a regressing wall clock to the prior durable value while
sequence remains the authoritative order.
§Errors
Returns JournalEventError for sequence exhaustion, clock regression,
or an unexpected integrity serialization failure.
Sourcepub const fn sequence(&self) -> JournalSequence
pub const fn sequence(&self) -> JournalSequence
Returns the one-based contiguous event sequence.
Sourcepub const fn recorded_at(&self) -> Timestamp
pub const fn recorded_at(&self) -> Timestamp
Returns the durable database clock observation.
Sourcepub const fn source(&self) -> &JournalEventSource
pub const fn source(&self) -> &JournalEventSource
Returns the trusted source marker.
Sourcepub const fn payload(&self) -> &JournalPayload
pub const fn payload(&self) -> &JournalPayload
Returns the schema-bound payload.
Sourcepub const fn payload_digest(&self) -> Digest
pub const fn payload_digest(&self) -> Digest
Returns the RFC 8785 payload checksum.
Sourcepub const fn intent_digest(&self) -> Digest
pub const fn intent_digest(&self) -> Digest
Returns the domain-separated append-intent checksum.
Sourcepub const fn previous_digest(&self) -> Option<Digest>
pub const fn previous_digest(&self) -> Option<Digest>
Returns the immediately preceding event checksum, if any.
Sourcepub fn head(&self) -> JournalHead
pub fn head(&self) -> JournalHead
Returns the exact durable head represented by this event.
Sourcepub fn matches_intent(&self, intent: &JournalEventIntent) -> bool
pub fn matches_intent(&self, intent: &JournalEventIntent) -> bool
Returns whether an idempotent retry is exactly the committed intent.
Trait Implementations§
Source§impl Clone for JournalEvent
impl Clone for JournalEvent
Source§impl Debug for JournalEvent
impl Debug for JournalEvent
Source§impl<'de> Deserialize<'de> for JournalEvent
impl<'de> Deserialize<'de> for JournalEvent
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl Eq for JournalEvent
Source§impl JsonSchema for JournalEvent
impl JsonSchema for JournalEvent
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more