Event

Struct Event 

Source
pub struct Event<P> {
    pub header: EventHeader,
    pub payload: P,
    pub hash_chain: Option<HashChain>,
}
Expand description

A complete event with header and payload.

The payload is generic to allow different event types to have different payload structures while sharing the same header format.

Fields§

§header: EventHeader§payload: P§hash_chain: Option<HashChain>

Hash chain for tamper-evident audit trail (Blake3 hash of parent + self). None for genesis events.

Implementations§

Source§

impl<P> Event<P>

Source

pub fn new(header: EventHeader, payload: P) -> Self

Create a new event with the given header and payload (genesis event, no hash chain).

Source

pub fn with_hash_chain( header: EventHeader, payload: P, hash_chain: HashChain, ) -> Self

Create a new event with the given header, payload, and hash chain.

Source

pub fn event_id(&self) -> EventId

Get the event ID.

Source

pub fn event_kind(&self) -> EventKind

Get the event kind.

Source

pub fn correlation_id(&self) -> EventId

Get the correlation ID.

Source

pub fn position(&self) -> DagPosition

Get the DAG position.

Source

pub fn map_payload<Q, F: FnOnce(P) -> Q>(self, f: F) -> Event<Q>

Map the payload to a different type.

Source§

impl<P: Serialize> Event<P>

Source

pub fn compute_hash(&self) -> [u8; 32]

Compute Blake3 hash of this event’s content (header + payload).

Hashes only header and payload — the hash_chain field is excluded to avoid a circular dependency (event_hash cannot include itself).

Source

pub fn verify(&self, parent_hash: &[u8; 32]) -> bool

Verify this event against a parent hash using Blake3. Returns true for genesis events (no hash chain).

Source

pub fn is_genesis(&self) -> bool

Check if this is a genesis event (no parent).

Trait Implementations§

Source§

impl<P: Clone> Clone for Event<P>

Source§

fn clone(&self) -> Event<P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<P> ComposeSchema for Event<P>
where P: ToSchema,

Source§

fn compose(generics: Vec<RefOr<Schema>>) -> RefOr<Schema>

Source§

impl<P: Debug> Debug for Event<P>

Source§

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

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

impl<'de, P> Deserialize<'de> for Event<P>
where P: Deserialize<'de>,

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<P: PartialEq> PartialEq for Event<P>

Source§

fn eq(&self, other: &Event<P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<P> Serialize for Event<P>
where P: Serialize,

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<P> ToSchema for Event<P>
where P: ToSchema,

Source§

fn name() -> Cow<'static, str>

Return name of the schema. Read more
Source§

fn schemas(schemas: &mut Vec<(String, RefOr<Schema>)>)

Implement reference [utoipa::openapi::schema::Schema]s for this type. Read more
Source§

impl<P: Eq> Eq for Event<P>

Source§

impl<P> StructuralPartialEq for Event<P>

Auto Trait Implementations§

§

impl<P> Freeze for Event<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for Event<P>
where P: RefUnwindSafe,

§

impl<P> Send for Event<P>
where P: Send,

§

impl<P> Sync for Event<P>
where P: Sync,

§

impl<P> Unpin for Event<P>
where P: Unpin,

§

impl<P> UnwindSafe for Event<P>
where P: UnwindSafe,

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.

§

impl<T> PartialSchema for T
where T: ComposeSchema + ?Sized,

§

fn schema() -> RefOr<Schema>

Return ref or schema of implementing type that can then be used to construct combined schemas.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

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