pub struct Event {
pub id: String,
pub subject: String,
pub category: String,
pub event_type: String,
pub version: u32,
pub payload: Value,
pub summary: String,
pub source: String,
pub timestamp: u64,
pub metadata: HashMap<String, String>,
}Expand description
A single event in the system
Events are published to subjects following the dot-separated convention:
events.<category>.<topic> (e.g., events.market.forex.usd_cny)
Fields§
§id: StringUnique event identifier (evt-
subject: StringSubject this event was published to
category: StringTop-level category for grouping (e.g., “market”, “system”)
event_type: StringEvent type identifier (e.g., “forex.rate_change”, “deploy.completed”)
Used by schema registry to look up validation rules. Defaults to empty string for untyped events.
version: u32Schema version for this event type (e.g., 1, 2, 3)
Incremented when the payload schema changes. Defaults to 1 for new events.
payload: ValueEvent payload — arbitrary JSON data
summary: StringHuman-readable summary
source: StringSource system or service that produced this event
timestamp: u64Unix timestamp in milliseconds
metadata: HashMap<String, String>Optional key-value metadata
Implementations§
Source§impl Event
impl Event
Sourcepub fn new(
subject: impl Into<String>,
category: impl Into<String>,
summary: impl Into<String>,
source: impl Into<String>,
payload: Value,
) -> Self
pub fn new( subject: impl Into<String>, category: impl Into<String>, summary: impl Into<String>, source: impl Into<String>, payload: Value, ) -> Self
Create a new event with auto-generated id and timestamp
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>,
Source§impl From<Event> for CloudEvent
Convert an A3S Event to a CloudEvent (lossless)
impl From<Event> for CloudEvent
Convert an A3S Event to a CloudEvent (lossless)
A3S-specific fields are stored as extension attributes:
a3scategory— Event.categorya3sversion— Event.versiona3ssummary— Event.summarya3stimestamp— Event.timestamp (Unix ms)a3smeta_<key>— each metadata entry
Source§impl TryFrom<CloudEvent> for Event
Convert a CloudEvent back to an A3S Event
impl TryFrom<CloudEvent> for Event
Convert a CloudEvent back to an A3S Event
Extracts A3S-specific fields from extension attributes. Fails if required A3S extensions are missing.