From e5a74441d78cc36e2993445efba78a73d86083f2 Mon Sep 17 00:00:00 2001 From: lz1998 <875543533@qq.com> Date: Tue, 14 Nov 2023 13:54:54 +0800 Subject: [PATCH] update --- axum-core/src/ext_traits/request.rs | 15 +++++++++------ axum-core/src/ext_traits/request_parts.rs | 13 ++++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/axum-core/src/ext_traits/request.rs b/axum-core/src/ext_traits/request.rs index 1f8a59ea98..54accff145 100644 --- a/axum-core/src/ext_traits/request.rs +++ b/axum-core/src/ext_traits/request.rs @@ -261,27 +261,30 @@ pub trait RequestExt: sealed::Sealed + Sized { } impl RequestExt for Request { - async fn extract(self) -> Result + fn extract(self) -> impl Future> + Send where E: FromRequest<(), M> + 'static, M: 'static, { - self.extract_with_state(&()).await + self.extract_with_state(&()) } - async fn extract_with_state(self, state: &S) -> Result + fn extract_with_state( + self, + state: &S, + ) -> impl Future> + Send where E: FromRequest + 'static, S: Send + Sync, { - E::from_request(self, state).await + E::from_request(self, state) } - async fn extract_parts(&mut self) -> Result + fn extract_parts(&mut self) -> impl Future> + Send where E: FromRequestParts<()> + 'static, { - self.extract_parts_with_state(&()).await + self.extract_parts_with_state(&()) } async fn extract_parts_with_state<'a, E, S>( diff --git a/axum-core/src/ext_traits/request_parts.rs b/axum-core/src/ext_traits/request_parts.rs index 7b3955dc0f..9e1a3d1c16 100644 --- a/axum-core/src/ext_traits/request_parts.rs +++ b/axum-core/src/ext_traits/request_parts.rs @@ -52,7 +52,7 @@ pub trait RequestPartsExt: sealed::Sealed + Sized { /// } /// } /// ``` - fn extract(&mut self) -> impl Future> + Send + '_ + fn extract(&mut self) -> impl Future> + Send where E: FromRequestParts<()> + 'static; @@ -115,19 +115,22 @@ pub trait RequestPartsExt: sealed::Sealed + Sized { } impl RequestPartsExt for Parts { - async fn extract(&mut self) -> Result + fn extract(&mut self) -> impl Future> + Send where E: FromRequestParts<()> + 'static, { - self.extract_with_state(&()).await + self.extract_with_state(&()) } - async fn extract_with_state<'a, E, S>(&'a mut self, state: &'a S) -> Result + fn extract_with_state<'a, E, S>( + &'a mut self, + state: &'a S, + ) -> impl Future> + Send + 'a where E: FromRequestParts + 'static, S: Send + Sync, { - E::from_request_parts(self, state).await + E::from_request_parts(self, state) } }