cloudevents/binding/
mod.rs1#[cfg_attr(docsrs, doc(cfg(feature = "actix")))]
4#[cfg(feature = "actix")]
5pub mod actix;
6#[cfg_attr(docsrs, doc(cfg(feature = "axum")))]
7#[cfg(feature = "axum")]
8pub mod axum;
9
10#[cfg_attr(
11 docsrs,
12 doc(cfg(any(
13 feature = "http-binding",
14 feature = "reqwest",
15 feature = "axum",
16 feature = "poem"
17 )))
18)]
19#[cfg(any(
20 feature = "http-binding",
21 feature = "reqwest",
22 feature = "axum",
23 feature = "poem"
24))]
25pub mod http;
26
27#[cfg_attr(
28 docsrs,
29 doc(cfg(any(feature = "http-0-2-binding", feature = "actix", feature = "warp",)))
30)]
31#[cfg(any(feature = "http-0-2-binding", feature = "actix", feature = "warp",))]
32pub mod http_0_2;
33
34#[cfg_attr(docsrs, doc(cfg(feature = "nats")))]
35#[cfg(feature = "nats")]
36pub mod nats;
37#[cfg_attr(docsrs, doc(cfg(feature = "poem")))]
38#[cfg(feature = "poem")]
39pub mod poem;
40#[cfg_attr(docsrs, doc(cfg(feature = "rdkafka")))]
41#[cfg(feature = "rdkafka")]
42pub mod rdkafka;
43#[cfg_attr(docsrs, doc(cfg(feature = "reqwest")))]
44#[cfg(feature = "reqwest")]
45pub mod reqwest;
46#[cfg_attr(docsrs, doc(cfg(feature = "warp")))]
47#[cfg(feature = "warp")]
48pub mod warp;
49
50#[cfg(feature = "rdkafka")]
51pub(crate) mod kafka {
52 pub static SPEC_VERSION_HEADER: &str = "ce_specversion";
53 pub fn header_prefix(name: &str) -> String {
54 super::header_prefix("ce_", name)
55 }
56}
57
58pub(crate) static CLOUDEVENTS_JSON_HEADER: &str = "application/cloudevents+json";
59pub(crate) static CLOUDEVENTS_BATCH_JSON_HEADER: &str = "application/cloudevents-batch+json";
60pub(crate) static CONTENT_TYPE: &str = "content-type";
61
62fn header_prefix(prefix: &str, name: &str) -> String {
63 if name == "datacontenttype" {
64 CONTENT_TYPE.to_string()
65 } else {
66 [prefix, name].concat()
67 }
68}
69
70#[macro_export]
71macro_rules! header_value_to_str {
72 ($header_value:expr) => {
73 $header_value
74 .to_str()
75 .map_err(|e| $crate::message::Error::Other {
76 source: Box::new(e),
77 })
78 };
79}