Both warp and reqwest use the HeaderMap from the http crate. Actix has its own. Fortunately, both contain (HeaderName, HeaderValue) tuples. Further, actix uses a conflicting version of the bytes crate, so I store a Vec<u8> instead of a Bytes member in the Deserializer struct. Not sure if that's a problem, but the tests pass. :) We use an associated type in the Headers trait to facilitate static dispatch for warp/reqwest since their concrete iterator is public, but the actix Iter struct is private, so we use a Box for its impl. We're using AsHeaderName for the get() param to avoid having to call as_str() on any header constants, but of course actix uses its own AsName trait, which isn't public, so we must call as_str() for the passed header name in its impl. Signed-off-by: Jim Crossley <jim@crossleys.org> |
||
|---|---|---|
| .github/workflows | ||
| example-projects | ||
| src | ||
| tests | ||
| .gitignore | ||
| CONTRIBUTING.md | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
README.md
CloudEvents SDK Rust

This project implements the CloudEvents Spec for Rust.
Note: This project is WIP under active development, hence all APIs are considered unstable.
Spec support
| v0.3 | v1.0 | |
|---|---|---|
| CloudEvents Core | ✓ | ✓ |
| AMQP Protocol Binding | ✕ | ✕ |
| AVRO Event Format | ✕ | ✕ |
| HTTP Protocol Binding | ✓ | ✓ |
| JSON Event Format | ✓ | ✓ |
| Kafka Protocol Binding | ✓ | ✓ |
| MQTT Protocol Binding | ✕ | ✕ |
| NATS Protocol Binding | ✕ | ✕ |
| Web hook | ✕ | ✕ |
Crate Structure
The core modules include definitions for the Event and
EventBuilder data structures, JSON serialization rules, and a
mechanism to support various Protocol Bindings, each of which is
enabled by a specific feature flag:
actix: Integration with actix.warp: Integration with warp.reqwest: Integration with reqwest.rdkafka: Integration with rdkafka.
This crate is continuously tested to work with GNU libc, WASM and musl toolchains.
Get Started
To get started, add the dependency to Cargo.toml, optionally
enabling your Protocol Binding of choice:
[dependencies]
cloudevents-sdk = { version = "0.4.0" }
Now you can start creating events:
use cloudevents::{EventBuilder, EventBuilderV10};
use url::Url;
let event = EventBuilderV10::new()
.id("aaa")
.source(Url::parse("http://localhost").unwrap())
.ty("example.demo")
.build()?;
Checkout the examples using our integrations to learn how to send and receive events:
Development & Contributing
If you're interested in contributing to sdk-rust, look at Contributing documentation
Community
- There are bi-weekly calls immediately following the Serverless/CloudEvents call at 9am PT (US Pacific). Which means they will typically start at 10am PT, but if the other call ends early then the SDK call will start early as well. See the CloudEvents meeting minutes to determine which week will have the call.
- Slack: #cloudeventssdk (or #cloudevents-sdk-rust) channel under CNCF's Slack workspace.
- Email: https://lists.cncf.io/g/cncf-cloudevents-sdk
- Contact for additional information: Francesco Guardiani (
@slinkydeveloperon slack).
Each SDK may have its own unique processes, tooling and guidelines, common
governance related material can be found in the
CloudEvents community
directory. In particular, in there you will find information concerning
how SDK projects are
managed,
guidelines
for how PR reviews and approval, and our
Code of Conduct
information.