Skip to main content

Event

Struct Event 

Source
pub struct Event {
Show 16 fields pub id: Uuid, pub namespace: String, pub verb: String, pub substrate: SubstrateKind, pub actor: String, pub kind: EventKind, pub outcome: EventOutcome, pub payload: Value, pub payload_schema_version: u32, pub profile_state_version: Option<u64>, pub duration_us: i64, pub target_id: Option<Uuid>, pub session_id: Option<Uuid>, pub aggregate_kind: Option<String>, pub aggregate_id: Option<Uuid>, pub created_at: i64,
}
Expand description

Storage-level event record. Every verb execution produces one. Immutable once appended; projection rows are written beside it at append time.

Fields§

§id: Uuid§namespace: String§verb: String§substrate: SubstrateKind§actor: String§kind: EventKind§outcome: EventOutcome§payload: Value§payload_schema_version: u32§profile_state_version: Option<u64>§duration_us: i64§target_id: Option<Uuid>§session_id: Option<Uuid>§aggregate_kind: Option<String>§aggregate_id: Option<Uuid>§created_at: i64

Implementations§

Source§

impl Event

Source

pub fn new( namespace: impl Into<String>, verb: impl Into<String>, kind: EventKind, substrate: SubstrateKind, actor: impl Into<String>, ) -> Self

Create a new event with a generated UUID and current timestamp.

Source

pub fn with_outcome(self, o: EventOutcome) -> Self

Set the event outcome (success/failure).

Source

pub fn with_payload(self, payload: Value) -> Self

Set the event payload JSON.

Source

pub fn with_payload_schema_version(self, version: u32) -> Self

Set the payload schema version for forward compatibility.

Source

pub fn with_profile_state_version(self, version: u64) -> Self

Set the brain profile state version at event time.

Source

pub fn with_duration_us(self, us: i64) -> Self

Set the operation duration in microseconds.

Source

pub fn with_target(self, id: Uuid) -> Self

Set the target entity/note ID for this event.

Source

pub fn with_session_id(self, id: Uuid) -> Self

Set the session ID for correlating related events.

Source

pub fn with_aggregate(self, kind: impl Into<String>, id: Uuid) -> Self

Set the aggregate kind and ID for event-sourced projections.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

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 Event

Source§

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

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

impl<'de> Deserialize<'de> for Event

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 Serialize for Event

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

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnsafeUnpin for Event

§

impl UnwindSafe for Event

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