Skip to content

Commit a42c5b6

Browse files
authored
Use Rust core async trait support (#41)
1 parent db0ef39 commit a42c5b6

File tree

3 files changed

+1
-28
lines changed

3 files changed

+1
-28
lines changed

Cargo.lock

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ napi-support = ["dep:napi", "dep:napi-derive", "dep:napi-build"]
2222
napi-build = { version = "2", optional = true }
2323

2424
[dependencies]
25-
async-trait = "0.1.88"
2625
bytes = "1.10.1"
2726
http = "1.0"
2827
# http-body = "1.0"

src/handler.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
//!
1515
//! struct HelloHandler;
1616
//!
17-
//! #[async_trait::async_trait]
1817
//! impl Handler for HelloHandler {
1918
//! type Error = std::convert::Infallible;
2019
//!
@@ -41,11 +40,10 @@
4140
//! header_value: &'static str,
4241
//! }
4342
//!
44-
//! #[async_trait::async_trait]
4543
//! impl<H, B> Handler<B> for AddHeaderHandler<H>
4644
//! where
4745
//! H: Handler<B> + std::marker::Sync,
48-
//! for<'async_trait> B: std::marker::Send + 'async_trait
46+
//! B: std::marker::Send
4947
//! {
5048
//! type Error = H::Error;
5149
//!
@@ -62,7 +60,6 @@
6260
//! // Usage
6361
//! struct ApiHandler;
6462
//!
65-
//! #[async_trait::async_trait]
6663
//! impl Handler for ApiHandler {
6764
//! type Error = std::convert::Infallible;
6865
//! async fn handle(&self, _req: http::Request<BytesMut>) -> Result<http::Response<BytesMut>, Self::Error> {
@@ -101,7 +98,6 @@ use bytes::BytesMut;
10198
///
10299
/// struct MyHandler;
103100
///
104-
/// #[async_trait::async_trait]
105101
/// impl Handler for MyHandler {
106102
/// type Error = std::convert::Infallible;
107103
///
@@ -122,7 +118,6 @@ use bytes::BytesMut;
122118
///
123119
/// struct StringHandler;
124120
///
125-
/// #[async_trait::async_trait]
126121
/// impl Handler<String> for StringHandler {
127122
/// type Error = std::convert::Infallible;
128123
///
@@ -137,7 +132,6 @@ use bytes::BytesMut;
137132
/// }
138133
/// }
139134
/// ```
140-
#[async_trait::async_trait]
141135
pub trait Handler<B = BytesMut> {
142136
/// The error type returned by the handler
143137
type Error;
@@ -157,7 +151,6 @@ mod tests {
157151
/// Example handler that echoes the request body
158152
pub struct EchoHandler;
159153

160-
#[async_trait::async_trait]
161154
impl Handler<Bytes> for EchoHandler {
162155
type Error = http::Error;
163156

@@ -187,7 +180,6 @@ mod tests {
187180
/// Test handler that adds logging
188181
struct LoggingHandler;
189182

190-
#[async_trait::async_trait]
191183
impl Handler<Bytes> for LoggingHandler {
192184
type Error = String;
193185

@@ -229,7 +221,6 @@ mod tests {
229221
/// Test handler that uses socket info
230222
struct SocketAwareHandler;
231223

232-
#[async_trait::async_trait]
233224
impl Handler<Bytes> for SocketAwareHandler {
234225
type Error = String;
235226

@@ -285,7 +276,6 @@ mod tests {
285276
/// Test handler that returns errors
286277
struct ErrorHandler;
287278

288-
#[async_trait::async_trait]
289279
impl Handler<Bytes> for ErrorHandler {
290280
type Error = String;
291281

@@ -313,7 +303,6 @@ mod tests {
313303
/// Test handler that sets an exception
314304
struct ExceptionHandler;
315305

316-
#[async_trait::async_trait]
317306
impl Handler<Bytes> for ExceptionHandler {
318307
type Error = std::convert::Infallible;
319308

@@ -351,7 +340,6 @@ mod tests {
351340
/// Test handler that works with String bodies
352341
struct StringBodyHandler;
353342

354-
#[async_trait::async_trait]
355343
impl Handler<String> for StringBodyHandler {
356344
type Error = std::convert::Infallible;
357345

@@ -430,7 +418,6 @@ mod tests {
430418
/// Generic echo handler that works with any cloneable body type
431419
pub struct GenericEchoHandler;
432420

433-
#[async_trait::async_trait]
434421
impl Handler<Bytes> for GenericEchoHandler {
435422
type Error = http::Error;
436423

@@ -444,7 +431,6 @@ mod tests {
444431
}
445432
}
446433

447-
#[async_trait::async_trait]
448434
impl Handler<Vec<u8>> for GenericEchoHandler {
449435
type Error = http::Error;
450436

0 commit comments

Comments
 (0)