Skip to main content

CloudEvent

Struct CloudEvent 

Source
pub struct CloudEvent {
    pub specversion: String,
    pub id: String,
    pub source: String,
    pub event_type: String,
    pub datacontenttype: Option<String>,
    pub dataschema: Option<String>,
    pub subject: Option<String>,
    pub time: Option<String>,
    pub data: Option<Value>,
    pub extensions: HashMap<String, Value>,
}
Expand description

CloudEvents v1.0 envelope

Required attributes: specversion, id, source, type. Optional attributes: datacontenttype, dataschema, subject, time. Extension attributes stored in extensions.

Fields§

§specversion: String

CloudEvents spec version (always “1.0”)

§id: String

Event identifier (maps to Event.id)

§source: String

Event source (maps to Event.source)

§event_type: String

Event type (maps to Event.event_type, or “a3s.event” for untyped)

§datacontenttype: Option<String>

Data content type

§dataschema: Option<String>

Data schema URI

§subject: Option<String>

Event subject (maps to Event.subject)

§time: Option<String>

Timestamp in RFC 3339 format

§data: Option<Value>

Event payload

§extensions: HashMap<String, Value>

Extension attributes (includes a3s-prefixed fields)

Implementations§

Source§

impl CloudEvent

Source

pub fn new( id: impl Into<String>, source: impl Into<String>, event_type: impl Into<String>, ) -> Self

Create a new CloudEvent with required attributes

Source

pub fn with_data(self, data: Value) -> Self

Set the data payload

Source

pub fn with_subject(self, subject: impl Into<String>) -> Self

Set the subject

Source

pub fn with_time(self, time: impl Into<String>) -> Self

Set the time

Source

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

Add an extension attribute

Trait Implementations§

Source§

impl Clone for CloudEvent

Source§

fn clone(&self) -> CloudEvent

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 CloudEvent

Source§

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

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

impl<'de> Deserialize<'de> for CloudEvent

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

Source§

fn eq(&self, other: &CloudEvent) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for CloudEvent

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.
Source§

impl StructuralPartialEq for CloudEvent

Auto Trait Implementations§

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>,