diff options
Diffstat (limited to 'axum-core/src/ext_traits/request_parts.rs')
-rw-r--r-- | axum-core/src/ext_traits/request_parts.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/axum-core/src/ext_traits/request_parts.rs b/axum-core/src/ext_traits/request_parts.rs index e7063f4d..9e1a3d1c 100644 --- a/axum-core/src/ext_traits/request_parts.rs +++ b/axum-core/src/ext_traits/request_parts.rs @@ -1,6 +1,6 @@ use crate::extract::FromRequestParts; -use futures_util::future::BoxFuture; use http::request::Parts; +use std::future::Future; mod sealed { pub trait Sealed {} @@ -21,7 +21,6 @@ pub trait RequestPartsExt: sealed::Sealed + Sized { /// response::{Response, IntoResponse}, /// http::request::Parts, /// RequestPartsExt, - /// async_trait, /// }; /// use std::collections::HashMap; /// @@ -30,7 +29,6 @@ pub trait RequestPartsExt: sealed::Sealed + Sized { /// query_params: HashMap<String, String>, /// } /// - /// #[async_trait] /// impl<S> FromRequestParts<S> for MyExtractor /// where /// S: Send + Sync, @@ -54,7 +52,7 @@ pub trait RequestPartsExt: sealed::Sealed + Sized { /// } /// } /// ``` - fn extract<E>(&mut self) -> BoxFuture<'_, Result<E, E::Rejection>> + fn extract<E>(&mut self) -> impl Future<Output = Result<E, E::Rejection>> + Send where E: FromRequestParts<()> + 'static; @@ -70,14 +68,12 @@ pub trait RequestPartsExt: sealed::Sealed + Sized { /// response::{Response, IntoResponse}, /// http::request::Parts, /// RequestPartsExt, - /// async_trait, /// }; /// /// struct MyExtractor { /// requires_state: RequiresState, /// } /// - /// #[async_trait] /// impl<S> FromRequestParts<S> for MyExtractor /// where /// String: FromRef<S>, @@ -97,7 +93,6 @@ pub trait RequestPartsExt: sealed::Sealed + Sized { /// struct RequiresState { /* ... */ } /// /// // some extractor that requires a `String` in the state - /// #[async_trait] /// impl<S> FromRequestParts<S> for RequiresState /// where /// String: FromRef<S>, @@ -113,14 +108,14 @@ pub trait RequestPartsExt: sealed::Sealed + Sized { fn extract_with_state<'a, E, S>( &'a mut self, state: &'a S, - ) -> BoxFuture<'a, Result<E, E::Rejection>> + ) -> impl Future<Output = Result<E, E::Rejection>> + Send + 'a where E: FromRequestParts<S> + 'static, S: Send + Sync; } impl RequestPartsExt for Parts { - fn extract<E>(&mut self) -> BoxFuture<'_, Result<E, E::Rejection>> + fn extract<E>(&mut self) -> impl Future<Output = Result<E, E::Rejection>> + Send where E: FromRequestParts<()> + 'static, { @@ -130,7 +125,7 @@ impl RequestPartsExt for Parts { fn extract_with_state<'a, E, S>( &'a mut self, state: &'a S, - ) -> BoxFuture<'a, Result<E, E::Rejection>> + ) -> impl Future<Output = Result<E, E::Rejection>> + Send + 'a where E: FromRequestParts<S> + 'static, S: Send + Sync, @@ -148,7 +143,6 @@ mod tests { ext_traits::tests::{RequiresState, State}, extract::FromRef, }; - use async_trait::async_trait; use http::{Method, Request}; #[tokio::test] @@ -181,7 +175,6 @@ mod tests { from_state: String, } - #[async_trait] impl<S> FromRequestParts<S> for WorksForCustomExtractor where S: Send + Sync, |