Skip to content

Commit e650033

Browse files
authored
Merge pull request #95 from slinkydeveloper/docs
Another round of docs fix + cleanups
2 parents d1281e7 + 4e3c023 commit e650033

33 files changed

+221
-117
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ repository = "https://github.com/cloudevents/sdk-rust"
1111
exclude = [
1212
".github/*"
1313
]
14+
categories = ["web-programming", "encoding", "data-structures"]
1415

1516
[lib]
1617
name = "cloudevents"
@@ -36,6 +37,7 @@ uuid = { version = "^0.8", features = ["v4", "wasm-bindgen"] }
3637
[dev-dependencies]
3738
rstest = "0.6"
3839
claim = "0.3.1"
40+
version-sync = "^0.9"
3941

4042
[workspace]
4143
members = [

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Note: This project is WIP under active development, hence all APIs are considere
3030
To get started, add the dependency to `Cargo.toml`:
3131

3232
```toml
33+
[dependencies]
3334
cloudevents-sdk = "0.2.0"
3435
```
3536

@@ -43,8 +44,7 @@ let event = EventBuilderV10::new()
4344
.id("aaa")
4445
.source(Url::parse("http://localhost").unwrap())
4546
.ty("example.demo")
46-
.build()
47-
.unwrap();
47+
.build()?;
4848
```
4949

5050
Checkout the examples using our integrations to learn how to send and receive events:

cloudevents-sdk-actix-web/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ description = "CloudEvents official Rust SDK - Actix-Web integration"
88
documentation = "https://docs.rs/cloudevents-sdk-actix-web"
99
repository = "https://github.com/cloudevents/sdk-rust"
1010
readme = "README.md"
11+
categories = ["web-programming", "encoding", "web-programming::http-server"]
1112

1213
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1314

@@ -23,4 +24,5 @@ futures = "^0.3"
2324
[dev-dependencies]
2425
url = { version = "^2.1", features = ["serde"] }
2526
serde_json = "^1.0"
26-
chrono = { version = "^0.4", features = ["serde"] }
27+
chrono = { version = "^0.4", features = ["serde"] }
28+
version-sync = "^0.9"

cloudevents-sdk-actix-web/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! To deserialize an HTTP request as CloudEvent:
44
//!
55
//! ```
6-
//! use cloudevents_sdk_actix_web::RequestExt;
6+
//! use cloudevents_sdk_actix_web::HttpRequestExt;
77
//! use actix_web::{HttpRequest, web, post};
88
//!
99
//! #[post("/")]
@@ -41,14 +41,17 @@
4141
//!
4242
//! Check out the [cloudevents-sdk](https://docs.rs/cloudevents-sdk) docs for more details on how to use [`cloudevents::Event`]
4343
44+
#![doc(html_root_url = "https://docs.rs/cloudevents-sdk-actix-web/0.2.0")]
45+
#![deny(broken_intra_doc_links)]
46+
4447
#[macro_use]
4548
mod headers;
4649
mod server_request;
4750
mod server_response;
4851

4952
pub use server_request::request_to_event;
5053
pub use server_request::HttpRequestDeserializer;
51-
pub use server_request::RequestExt;
54+
pub use server_request::HttpRequestExt;
5255
pub use server_response::event_to_response;
5356
pub use server_response::HttpResponseBuilderExt;
5457
pub use server_response::HttpResponseSerializer;

cloudevents-sdk-actix-web/src/server_request.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,19 @@ pub async fn request_to_event(
113113
}
114114

115115
/// Extention Trait for [`HttpRequest`] which acts as a wrapper for the function [`request_to_event()`].
116+
///
117+
/// This trait is sealed and cannot be implemented for types outside of this crate.
116118
#[async_trait(?Send)]
117-
pub trait RequestExt {
119+
pub trait HttpRequestExt: private::Sealed {
120+
/// Convert this [`HttpRequest`] into an [`Event`].
118121
async fn to_event(
119122
&self,
120123
mut payload: web::Payload,
121124
) -> std::result::Result<Event, actix_web::error::Error>;
122125
}
123126

124127
#[async_trait(?Send)]
125-
impl RequestExt for HttpRequest {
128+
impl HttpRequestExt for HttpRequest {
126129
async fn to_event(
127130
&self,
128131
payload: web::Payload,
@@ -131,6 +134,12 @@ impl RequestExt for HttpRequest {
131134
}
132135
}
133136

137+
mod private {
138+
// Sealing the RequestExt
139+
pub trait Sealed {}
140+
impl Sealed for actix_web::HttpRequest {}
141+
}
142+
134143
#[cfg(test)]
135144
mod tests {
136145
use super::*;

cloudevents-sdk-actix-web/src/server_response.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ pub async fn event_to_response(
7676
.map_err(actix_web::error::ErrorBadRequest)
7777
}
7878

79-
/// Extention Trait for [`HttpResponseBuilder`] which acts as a wrapper for the function [`event_to_response()`].
79+
/// Extension Trait for [`HttpResponseBuilder`] which acts as a wrapper for the function [`event_to_response()`].
80+
///
81+
/// This trait is sealed and cannot be implemented for types outside of this crate.
8082
#[async_trait(?Send)]
81-
pub trait HttpResponseBuilderExt {
83+
pub trait HttpResponseBuilderExt: private::Sealed {
84+
/// Fill this [`HttpResponseBuilder`] with an [`Event`].
8285
async fn event(
8386
self,
8487
event: Event,
@@ -95,6 +98,12 @@ impl HttpResponseBuilderExt for HttpResponseBuilder {
9598
}
9699
}
97100

101+
// Sealing the HttpResponseBuilderExt
102+
mod private {
103+
pub trait Sealed {}
104+
impl Sealed for actix_web::dev::HttpResponseBuilder {}
105+
}
106+
98107
#[cfg(test)]
99108
mod tests {
100109
use super::*;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#[test]
2+
fn test_readme_deps() {
3+
version_sync::assert_markdown_deps_updated!("README.md");
4+
}
5+
6+
#[test]
7+
fn test_html_root_url() {
8+
version_sync::assert_html_root_url_updated!("src/lib.rs");
9+
}

cloudevents-sdk-rdkafka/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@ description = "CloudEvents official Rust SDK - Kafka integration"
88
documentation = "https://docs.rs/cloudevents-sdk-rdkafka"
99
repository = "https://github.com/cloudevents/sdk-rust"
1010
readme = "README.md"
11+
categories = ["web-programming", "encoding"]
1112

1213
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1314

1415
[dependencies]
1516
bytes = "^0.5"
1617
cloudevents-sdk = { version = "0.2.0", path = ".." }
1718
lazy_static = "1.4.0"
18-
rdkafka = { version = "^0.24", features = ["cmake-build"] }
19-
19+
rdkafka = { version = "^0.24", default-features = false }
2020

2121
[dev-dependencies]
2222
url = { version = "^2.1" }
2323
serde_json = "^1.0"
2424
chrono = { version = "^0.4", features = ["serde"] }
2525
futures = "0.3.5"
26+
rdkafka = { version = "^0.24" }
27+
version-sync = "^0.9"

cloudevents-sdk-rdkafka/src/kafka_consumer_record.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ pub fn record_to_event(msg: &impl Message) -> Result<Event> {
134134
MessageDeserializer::into_event(ConsumerRecordDeserializer::new(msg)?)
135135
}
136136

137-
/// Extension Trait for [`Message`] which acts as a wrapper for the function [`record_to_event()`]
138-
pub trait MessageExt {
137+
/// Extension Trait for [`Message`] which acts as a wrapper for the function [`record_to_event()`].
138+
///
139+
/// This trait is sealed and cannot be implemented for types outside of this crate.
140+
pub trait MessageExt: private::Sealed {
139141
/// Generates [`Event`] from [`BorrowedMessage`].
140142
fn to_event(&self) -> Result<Event>;
141143
}
@@ -152,6 +154,13 @@ impl MessageExt for OwnedMessage {
152154
}
153155
}
154156

157+
mod private {
158+
// Sealing the MessageExt
159+
pub trait Sealed {}
160+
impl Sealed for rdkafka::message::OwnedMessage {}
161+
impl Sealed for rdkafka::message::BorrowedMessage<'_> {}
162+
}
163+
155164
#[cfg(test)]
156165
mod tests {
157166
use super::*;

cloudevents-sdk-rdkafka/src/kafka_producer_record.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ impl StructuredSerializer<MessageRecord> for MessageRecord {
8888
}
8989

9090
/// Extension Trait for [`BaseRecord`] that fills the record with a [`MessageRecord`].
91-
pub trait BaseRecordExt<'a, K: ToBytes + ?Sized> {
91+
///
92+
/// This trait is sealed and cannot be implemented for types outside of this crate.
93+
pub trait BaseRecordExt<'a, K: ToBytes + ?Sized>: private::Sealed {
9294
/// Fill this [`BaseRecord`] with a [`MessageRecord`].
9395
fn message_record(
9496
self,
@@ -112,7 +114,9 @@ impl<'a, K: ToBytes + ?Sized> BaseRecordExt<'a, K> for BaseRecord<'a, K, Vec<u8>
112114
}
113115

114116
/// Extension Trait for [`FutureRecord`] that fills the record with a [`MessageRecord`].
115-
pub trait FutureRecordExt<'a, K: ToBytes + ?Sized> {
117+
///
118+
/// This trait is sealed and cannot be implemented for types outside of this crate.
119+
pub trait FutureRecordExt<'a, K: ToBytes + ?Sized>: private::Sealed {
116120
/// Fill this [`FutureRecord`] with a [`MessageRecord`].
117121
fn message_record(self, message_record: &'a MessageRecord) -> FutureRecord<'a, K, Vec<u8>>;
118122
}
@@ -128,3 +132,16 @@ impl<'a, K: ToBytes + ?Sized> FutureRecordExt<'a, K> for FutureRecord<'a, K, Vec
128132
self
129133
}
130134
}
135+
136+
mod private {
137+
// Sealing the FutureRecordExt and BaseRecordExt
138+
pub trait Sealed {}
139+
impl<K: rdkafka::message::ToBytes + ?Sized, V: rdkafka::message::ToBytes> Sealed
140+
for rdkafka::producer::FutureRecord<'_, K, V>
141+
{
142+
}
143+
impl<K: rdkafka::message::ToBytes + ?Sized, V: rdkafka::message::ToBytes> Sealed
144+
for rdkafka::producer::BaseRecord<'_, K, V>
145+
{
146+
}
147+
}

0 commit comments

Comments
 (0)