[−][src]Crate cloudevents
This crate implements the CloudEvents Spec for Rust.
use cloudevents::{EventBuilder, AttributesReader, EventBuilderV10}; use chrono::{Utc, DateTime}; use url::Url; let event = EventBuilderV10::new() .id("my_event.my_application") .source("http://localhost:8080") .ty("example.demo") .time(Utc::now()) .build()?; println!("CloudEvent Id: {}", event.id()); match event.time() { Some(t) => println!("CloudEvent Time: {}", t), None => println!("CloudEvent Time: None") }
This crate includes:
- The
Event
data structure, to represent CloudEvent (version 1.0 and 0.3) - The
EventBuilder
trait and implementations, to createEvent
instances - The implementation of
serde::Serialize
andserde::Deserialize
forEvent
to serialize/deserialize CloudEvents to/from JSON - Traits and utilities in
message
to implement Protocol Bindings
If you're looking for Protocol Binding implementations, look at crates:
- cloudevents-sdk-actix-web: Integration with Actix Web
- cloudevents-sdk-reqwest: Integration with reqwest
- cloudevents-sdk-rdkafka: Integration with rdkafka
Modules
event | Provides |
message | Provides facilities to implement Protocol Bindings. |
Structs
Event | Data structure that represents a CloudEvent.
It provides methods to get the attributes through |
EventBuilderV03 | Builder to create a CloudEvent V0.3 |
EventBuilderV10 | Builder to create a CloudEvent V1.0 |
Enums
Data | Event data attribute representation |
Traits
AttributesReader | Trait to get CloudEvents Context attributes. |
AttributesWriter | Trait to set CloudEvents Context attributes. |
EventBuilder | Trait to implement a builder for |