Expand description
CloudEvent conversion utilities.
This module provides a lightweight CloudEvent newtype that wraps a
[cloudevents_sdk::Event] and a blanket From implementation which turns
any Event from this crate into a CloudEvent.
§Example
use sourcerer::{Event as _, cloudevent::CloudEvent};
#[derive(Clone, Debug, Serialize, Deserialize)]
struct MyEvent;
impl sourcerer::Event for MyEvent {
fn event_type(&self) -> &'static str { "MyEvent" }
fn event_version(&self) -> u16 { 1 }
fn event_source(&self) -> &'static str { "urn:sourcerer:test" }
}
let ce: CloudEvent = my_event.into();A random UUID is generated for the CloudEvent id field and the source
attribute defaults to "urn:sourcerer:event". If you need more control
build the underlying event manually via the into_inner method.
Structs§
- Cloud
Event - Newtype wrapper around
cloudevents_sdk::Eventso we can legally provide a blanketFromimplementation without violating Rust’s orphan rules.