File tree Expand file tree Collapse file tree 4 files changed +27
-6
lines changed
cloudevents-sdk-actix-web Expand file tree Collapse file tree 4 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ description = "CloudEvents official Rust SDK - Actix-Web integration"
8
8
documentation = " https://docs.rs/cloudevents-sdk-actix-web"
9
9
repository = " https://github.com/cloudevents/sdk-rust"
10
10
readme = " README.md"
11
+ categories = [" web-programming" , " encoding" , " web-programming::http-server" ]
11
12
12
13
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
13
14
Original file line number Diff line number Diff line change 3
3
//! To deserialize an HTTP request as CloudEvent:
4
4
//!
5
5
//! ```
6
- //! use cloudevents_sdk_actix_web::RequestExt ;
6
+ //! use cloudevents_sdk_actix_web::HttpRequestExt ;
7
7
//! use actix_web::{HttpRequest, web, post};
8
8
//!
9
9
//! #[post("/")]
41
41
//!
42
42
//! Check out the [cloudevents-sdk](https://docs.rs/cloudevents-sdk) docs for more details on how to use [`cloudevents::Event`]
43
43
44
+ #![ deny( broken_intra_doc_links) ]
45
+
44
46
#[ macro_use]
45
47
mod headers;
46
48
mod server_request;
47
49
mod server_response;
48
50
49
51
pub use server_request:: request_to_event;
50
52
pub use server_request:: HttpRequestDeserializer ;
51
- pub use server_request:: RequestExt ;
53
+ pub use server_request:: HttpRequestExt ;
52
54
pub use server_response:: event_to_response;
53
55
pub use server_response:: HttpResponseBuilderExt ;
54
56
pub use server_response:: HttpResponseSerializer ;
Original file line number Diff line number Diff line change @@ -113,16 +113,19 @@ pub async fn request_to_event(
113
113
}
114
114
115
115
/// 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.
116
118
#[ async_trait( ?Send ) ]
117
- pub trait RequestExt {
119
+ pub trait HttpRequestExt : private:: Sealed {
120
+ /// Convert this [`HttpRequest`] into an [`Event`].
118
121
async fn to_event (
119
122
& self ,
120
123
mut payload : web:: Payload ,
121
124
) -> std:: result:: Result < Event , actix_web:: error:: Error > ;
122
125
}
123
126
124
127
#[ async_trait( ?Send ) ]
125
- impl RequestExt for HttpRequest {
128
+ impl HttpRequestExt for HttpRequest {
126
129
async fn to_event (
127
130
& self ,
128
131
payload : web:: Payload ,
@@ -131,6 +134,12 @@ impl RequestExt for HttpRequest {
131
134
}
132
135
}
133
136
137
+ mod private {
138
+ // Sealing the RequestExt
139
+ pub trait Sealed { }
140
+ impl Sealed for actix_web:: HttpRequest { }
141
+ }
142
+
134
143
#[ cfg( test) ]
135
144
mod tests {
136
145
use super :: * ;
Original file line number Diff line number Diff line change @@ -76,9 +76,12 @@ pub async fn event_to_response(
76
76
. map_err ( actix_web:: error:: ErrorBadRequest )
77
77
}
78
78
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.
80
82
#[ async_trait( ?Send ) ]
81
- pub trait HttpResponseBuilderExt {
83
+ pub trait HttpResponseBuilderExt : private:: Sealed {
84
+ /// Fill this [`HttpResponseBuilder`] with an [`Event`].
82
85
async fn event (
83
86
self ,
84
87
event : Event ,
@@ -95,6 +98,12 @@ impl HttpResponseBuilderExt for HttpResponseBuilder {
95
98
}
96
99
}
97
100
101
+ // Sealing the HttpResponseBuilderExt
102
+ mod private {
103
+ pub trait Sealed { }
104
+ impl Sealed for actix_web:: dev:: HttpResponseBuilder { }
105
+ }
106
+
98
107
#[ cfg( test) ]
99
108
mod tests {
100
109
use super :: * ;
You can’t perform that action at this time.
0 commit comments