Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lz1998 committed Nov 14, 2023
1 parent 42b76bd commit e5a7444
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
15 changes: 9 additions & 6 deletions axum-core/src/ext_traits/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,27 +261,30 @@ pub trait RequestExt: sealed::Sealed + Sized {
}

impl RequestExt for Request {
async fn extract<E, M>(self) -> Result<E, E::Rejection>
fn extract<E, M>(self) -> impl Future<Output = Result<E, E::Rejection>> + Send
where
E: FromRequest<(), M> + 'static,
M: 'static,
{
self.extract_with_state(&()).await
self.extract_with_state(&())
}

async fn extract_with_state<E, S, M>(self, state: &S) -> Result<E, E::Rejection>
fn extract_with_state<E, S, M>(
self,
state: &S,
) -> impl Future<Output = Result<E, E::Rejection>> + Send
where
E: FromRequest<S, M> + 'static,
S: Send + Sync,
{
E::from_request(self, state).await
E::from_request(self, state)
}

async fn extract_parts<E>(&mut self) -> Result<E, E::Rejection>
fn extract_parts<E>(&mut self) -> impl Future<Output = Result<E, E::Rejection>> + 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>(
Expand Down
13 changes: 8 additions & 5 deletions axum-core/src/ext_traits/request_parts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub trait RequestPartsExt: sealed::Sealed + Sized {
/// }
/// }
/// ```
fn extract<E>(&mut self) -> impl Future<Output = Result<E, E::Rejection>> + Send + '_
fn extract<E>(&mut self) -> impl Future<Output = Result<E, E::Rejection>> + Send
where
E: FromRequestParts<()> + 'static;

Expand Down Expand Up @@ -115,19 +115,22 @@ pub trait RequestPartsExt: sealed::Sealed + Sized {
}

impl RequestPartsExt for Parts {
async fn extract<E>(&mut self) -> Result<E, E::Rejection>
fn extract<E>(&mut self) -> impl Future<Output = Result<E, E::Rejection>> + 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<E, E::Rejection>
fn extract_with_state<'a, E, S>(
&'a mut self,
state: &'a S,
) -> impl Future<Output = Result<E, E::Rejection>> + Send + 'a
where
E: FromRequestParts<S> + 'static,
S: Send + Sync,
{
E::from_request_parts(self, state).await
E::from_request_parts(self, state)
}
}

Expand Down

0 comments on commit e5a7444

Please sign in to comment.