[−][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
Eventdata structure, to represent CloudEvent (version 1.0 and 0.3) - The
EventBuildertrait and implementations, to createEventinstances - The implementation of
serde::Serializeandserde::DeserializeforEventto serialize/deserialize CloudEvents to/from JSON - Traits and utilities in
messageto 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
Re-exports
pub use event::Event; |
Modules
| event | Provides |
| message | Provides facilities to implement Protocol Bindings. |
Structs
| 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 |