Skip to main content

EventRecord

Struct EventRecord 

Source
pub struct EventRecord {
    pub event_name: String,
    pub payload_codec: Cow<'static, str>,
    pub payload_codec_version: u16,
    pub payload: Vec<u8>,
    pub event_version: u64,
    pub sequence: u64,
    pub timestamp: SystemTime,
    pub metadata: HashMap<String, String>,
}
Expand description

Replayable aggregate event record stored in an event-sourced entity stream.

EventRecord is model history for aggregate hydration. It is not automatically a domain event or integration message; publishable messages belong in the outbox/bus boundary.

Fields§

§event_name: String§payload_codec: Cow<'static, str>

Payload codec name. Cow because virtually every event carries the crate’s own codec constant — the borrowed variant avoids one heap allocation per event created and per row decoded.

§payload_codec_version: u16§payload: Vec<u8>§event_version: u64§sequence: u64§timestamp: SystemTime§metadata: HashMap<String, String>

Implementations§

Source§

impl EventRecord

Source

pub fn new( event_name: impl Into<String>, payload: Vec<u8>, sequence: u64, ) -> Self

Source

pub fn new_versioned( event_name: impl Into<String>, payload: Vec<u8>, sequence: u64, version: u64, ) -> Self

Create an event record at a specific version.

Source

pub fn with_metadata( event_name: impl Into<String>, payload: Vec<u8>, sequence: u64, metadata: HashMap<String, String>, ) -> Self

Create an event record with metadata.

Source

pub fn decode<T: DeserializeOwned>(&self) -> Result<T, EventRecordError>

Deserialize the payload into the specified type.

Source

pub fn payload_bytes(&self) -> &[u8]

Get the raw payload bytes.

Source

pub fn meta(&self, key: &str) -> Option<&str>

Get a metadata value by key.

Source

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

Get the correlation ID, if set.

Source

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

Get the causation ID, if set.

Source

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

Get the W3C traceparent, if set.

Source

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

Get the W3C tracestate, if set.

Source

pub fn trace_context(&self) -> TraceContext

Extract W3C trace context from event metadata.

Trait Implementations§

Source§

impl Clone for EventRecord

Source§

fn clone(&self) -> EventRecord

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 EventRecord

Source§

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

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

impl<'de> Deserialize<'de> for EventRecord

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 PartialEq for EventRecord

Source§

fn eq(&self, other: &EventRecord) -> 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 EventRecord

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 EventRecord

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AggregateBuilder for T

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> Queueable for T

Source§

fn queued(self) -> QueuedRepository<Self, InMemoryLockManager>

Wrap with the default async lock manager. Pair with .aggregate::<T>() for per-aggregate serialization over the async repository surface.
Source§

fn queued_with<L: LockManager>( self, lock_manager: L, ) -> QueuedRepository<Self, L>

Wrap with a custom async lock manager.
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.