Skip to main content

Event

Struct Event 

Source
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: String

Unique event identifier (evt-)

§subject: String

Subject this event was published to

§category: String

Top-level category for grouping (e.g., “market”, “system”)

§event_type: String

Event 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: u32

Schema version for this event type (e.g., 1, 2, 3)

Incremented when the payload schema changes. Defaults to 1 for new events.

§payload: Value

Event payload — arbitrary JSON data

§summary: String

Human-readable summary

§source: String

Source system or service that produced this event

§timestamp: u64

Unix timestamp in milliseconds

§metadata: HashMap<String, String>

Optional key-value metadata

Implementations§

Source§

impl Event

Source

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

Source

pub fn typed( subject: impl Into<String>, category: impl Into<String>, event_type: impl Into<String>, version: u32, summary: impl Into<String>, source: impl Into<String>, payload: Value, ) -> Self

Create a typed event with explicit event_type and version

Source

pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Add a metadata entry

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a duplicate of the value. Read more
1.0.0 · 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 From<Event> for CloudEvent

Convert an A3S Event to a CloudEvent (lossless)

A3S-specific fields are stored as extension attributes:

  • a3scategory — Event.category
  • a3sversion — Event.version
  • a3ssummary — Event.summary
  • a3stimestamp — Event.timestamp (Unix ms)
  • a3smeta_<key> — each metadata entry
Source§

fn from(event: Event) -> Self

Converts to this type from the input type.
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
Source§

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.

Source§

type Error = EventError

The type returned in the event of a conversion error.
Source§

fn try_from(ce: CloudEvent) -> Result<Self>

Performs the conversion.

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,