pub struct Event {
pub id: Ulid,
pub aggregator_id: String,
pub aggregator_type: String,
pub version: u16,
pub name: String,
pub routing_key: Option<String>,
pub data: Vec<u8>,
pub metadata: Metadata,
pub timestamp: u64,
pub timestamp_subsec: u32,
}Expand description
A stored event in the event store.
Events are immutable records of facts that occurred in your domain. They contain serialized data and metadata, along with positioning information for the aggregate they belong to.
§Fields
id- Unique event identifier (ULID format for time-ordering)aggregator_id- The aggregate instance this event belongs toaggregator_type- Type name like"myapp/BankAccount"version- Sequence number within the aggregate (for optimistic concurrency)name- Event type name like"AccountOpened"routing_key- Optional key for event distribution/partitioningdata- Serialized event payload (bitcode format)metadata- Event metadata (seemetadata::Metadata)timestamp- When the event occurred (Unix seconds)timestamp_subsec- Sub-second precision (milliseconds)
§Serialization
Event data is serialized using bitcode
for compact binary representation. Use metadata::Event to deserialize typed events.
Fields§
§id: UlidUnique event identifier (ULID)
aggregator_id: StringID of the aggregate this event belongs to
aggregator_type: StringType name of the aggregate (e.g., “myapp/User”)
version: u16Version number of the aggregate after this event
name: StringEvent type name
routing_key: Option<String>Optional routing key for event distribution
data: Vec<u8>Serialized event data (bitcode format)
metadata: MetadataEvent metadata
timestamp: u64Unix timestamp when the event occurred (seconds)
timestamp_subsec: u32Sub-second precision (milliseconds)
Trait Implementations§
Source§impl Bind for Event
impl Bind for Event
Source§impl Cursor for Event
impl Cursor for Event
Source§type T = EventCursor
type T = EventCursor
The cursor data type (e.g.,
EventCursor)Source§fn serialize_cursor(&self) -> Result<Value, CursorError>
fn serialize_cursor(&self) -> Result<Value, CursorError>
Serializes cursor data to a base64
Value.Source§fn deserialize_cursor(value: &Value) -> Result<Self::T, CursorError>
fn deserialize_cursor(value: &Value) -> Result<Self::T, CursorError>
Deserializes cursor data from a base64
Value.impl StructuralPartialEq for Event
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnwindSafe for Event
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more