pub struct Event {
pub id: EventId,
pub event_type: String,
pub ts: DateTime<Utc>,
pub session_id: SessionId,
pub context: EventContext,
pub data: EventData,
pub metadata: Option<Value>,
pub tags: Option<Vec<String>>,
pub sequence: Option<i32>,
}Expand description
Standard event following the Everruns event protocol.
All events have a consistent structure:
id: Unique event identifier (format: event_{32-hex})type: Event type in dot notation (e.g., “input.message”, “reason.started”)ts: ISO 8601 timestamp with millisecond precisionsession_id: Session this event belongs to (format: session_{32-hex})context: Correlation context for tracingdata: Event-specific payload (typed via EventData enum)metadata: Optional arbitrary metadatatags: Optional list of tags for filtering
Fields§
§id: EventIdUnique event identifier (format: event_{32-hex})
event_type: StringEvent type in dot notation
ts: DateTime<Utc>Event timestamp
session_id: SessionIdSession this event belongs to (format: session_{32-hex})
context: EventContextCorrelation context
data: EventDataEvent-specific payload. The schema depends on the event type. See EventData documentation for the mapping of type to data schema.
metadata: Option<Value>Arbitrary metadata for the event
Tags for filtering and categorization
sequence: Option<i32>Sequence number within session (for ordering)
Implementations§
Source§impl Event
impl Event
Sourcepub fn new(
session_id: SessionId,
context: EventContext,
data: impl Into<EventData>,
) -> Self
pub fn new( session_id: SessionId, context: EventContext, data: impl Into<EventData>, ) -> Self
Create a new event with the given session_id, context, and typed data
The event type is automatically inferred from the data type.
Sourcepub fn with_id(
id: EventId,
session_id: SessionId,
context: EventContext,
data: impl Into<EventData>,
) -> Self
pub fn with_id( id: EventId, session_id: SessionId, context: EventContext, data: impl Into<EventData>, ) -> Self
Create an event with a specific ID (for testing or replay)
Sourcepub fn with_sequence(self, sequence: i32) -> Self
pub fn with_sequence(self, sequence: i32) -> Self
Set the sequence number
Sourcepub fn with_metadata(self, metadata: Value) -> Self
pub fn with_metadata(self, metadata: Value) -> Self
Set metadata
Set tags
Sourcepub fn session_uuid(&self) -> Uuid
pub fn session_uuid(&self) -> Uuid
Get the session_id as raw UUID
Sourcepub fn is_message_event(&self) -> bool
pub fn is_message_event(&self) -> bool
Check if this is an input or output message event
Sourcepub fn is_ephemeral(&self) -> bool
pub fn is_ephemeral(&self) -> bool
Whether this event is ephemeral. Delta events may be delivered to
listeners without ever being inserted into the events table, so any
downstream storage that holds an FK to events.id must treat the
reference as best-effort and skip it for ephemeral sources.
Mirror of EventRequest::is_ephemeral; both delegate to
is_ephemeral_event_type so the match set stays in lockstep.
Sourcepub fn is_input_event(&self) -> bool
pub fn is_input_event(&self) -> bool
Check if this is an input event
Sourcepub fn is_output_event(&self) -> bool
pub fn is_output_event(&self) -> bool
Check if this is an output event
Sourcepub fn is_atom_event(&self) -> bool
pub fn is_atom_event(&self) -> bool
Check if this is an atom lifecycle event
Sourcepub fn is_turn_event(&self) -> bool
pub fn is_turn_event(&self) -> bool
Check if this is a turn lifecycle event
Sourcepub fn is_session_event(&self) -> bool
pub fn is_session_event(&self) -> bool
Check if this is a session lifecycle event
Sourcepub fn is_unsupported(&self) -> bool
pub fn is_unsupported(&self) -> bool
Check if this event has unsupported data. Unsupported events should be filtered before API responses.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Event
impl<'de> Deserialize<'de> for Event
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>,
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> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request