Skip to content

Commit

Permalink
add Send
Browse files Browse the repository at this point in the history
  • Loading branch information
lz1998 committed Nov 13, 2023
1 parent 5f9b379 commit 42b76bd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions axum-core/src/ext_traits/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub trait RequestExt: sealed::Sealed + Sized {
/// }
/// }
/// ```
fn extract<E, M>(self) -> impl Future<Output = Result<E, E::Rejection>>
fn extract<E, M>(self) -> impl Future<Output = Result<E, E::Rejection>> + Send
where
E: FromRequest<(), M> + 'static,
M: 'static;
Expand Down Expand Up @@ -123,7 +123,7 @@ pub trait RequestExt: sealed::Sealed + Sized {
fn extract_with_state<E, S, M>(
self,
state: &S,
) -> impl Future<Output = Result<E, E::Rejection>>
) -> impl Future<Output = Result<E, E::Rejection>> + Send
where
E: FromRequest<S, M> + 'static,
S: Send + Sync;
Expand Down Expand Up @@ -176,7 +176,7 @@ pub trait RequestExt: sealed::Sealed + Sized {
/// }
/// }
/// ```
fn extract_parts<E>(&mut self) -> impl Future<Output = Result<E, E::Rejection>>
fn extract_parts<E>(&mut self) -> impl Future<Output = Result<E, E::Rejection>> + Send
where
E: FromRequestParts<()> + 'static;

Expand Down Expand Up @@ -244,7 +244,7 @@ pub trait RequestExt: sealed::Sealed + Sized {
fn extract_parts_with_state<'a, E, S>(
&'a mut self,
state: &'a S,
) -> impl Future<Output = Result<E, E::Rejection>> + 'a
) -> impl Future<Output = Result<E, E::Rejection>> + Send + 'a
where
E: FromRequestParts<S> + 'static,
S: Send + Sync;
Expand Down
4 changes: 2 additions & 2 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>> + '_
fn extract<E>(&mut self) -> impl Future<Output = Result<E, E::Rejection>> + Send + '_
where
E: FromRequestParts<()> + 'static;

Expand Down Expand Up @@ -108,7 +108,7 @@ pub trait RequestPartsExt: sealed::Sealed + Sized {
fn extract_with_state<'a, E, S>(
&'a mut self,
state: &'a S,
) -> impl Future<Output = Result<E, E::Rejection>> + 'a
) -> impl Future<Output = Result<E, E::Rejection>> + Send + 'a
where
E: FromRequestParts<S> + 'static,
S: Send + Sync;
Expand Down
7 changes: 5 additions & 2 deletions examples/error-handling-and-dependency-injection/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,13 @@ type DynUserRepo = Arc<dyn UserRepo + Send + Sync>;
/// A trait that defines things a user repo might support.
trait UserRepo {
/// Loop up a user by their id.
fn find(&self, user_id: Uuid) -> impl Future<Output = Result<User, UserRepoError>>;
fn find(&self, user_id: Uuid) -> impl Future<Output = Result<User, UserRepoError>> + Send;

/// Create a new user.
fn create(&self, params: CreateUser) -> impl Future<Output = Result<User, UserRepoError>>;
fn create(
&self,
params: CreateUser,
) -> impl Future<Output = Result<User, UserRepoError>> + Send;
}

#[derive(Debug, Serialize)]
Expand Down

0 comments on commit 42b76bd

Please sign in to comment.