mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-27 00:00:24 +02:00
Always store state in an Arc (#1270)
* Add extension and state benchmarks * wip * Arc the state everywhere * don't require `S: Clone` * fix example
This commit is contained in:
@@ -82,7 +82,7 @@ struct PrintRequestBody;
|
||||
#[async_trait]
|
||||
impl<S> FromRequest<S, BoxBody> for PrintRequestBody
|
||||
where
|
||||
S: Send + Clone,
|
||||
S: Clone + Send + Sync,
|
||||
{
|
||||
type Rejection = Response;
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ struct Json<T>(T);
|
||||
#[async_trait]
|
||||
impl<S, B, T> FromRequest<S, B> for Json<T>
|
||||
where
|
||||
S: Send,
|
||||
S: Send + Sync,
|
||||
// these trait bounds are copied from `impl FromRequest for axum::Json`
|
||||
T: DeserializeOwned,
|
||||
B: axum::body::HttpBody + Send,
|
||||
|
||||
@@ -57,7 +57,7 @@ where
|
||||
// these trait bounds are copied from `impl FromRequest for axum::extract::path::Path`
|
||||
T: DeserializeOwned + Send,
|
||||
B: Send,
|
||||
S: Send,
|
||||
S: Send + Sync,
|
||||
{
|
||||
type Rejection = (StatusCode, axum::Json<PathError>);
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ impl AuthBody {
|
||||
#[async_trait]
|
||||
impl<S, B> FromRequest<S, B> for Claims
|
||||
where
|
||||
S: Send,
|
||||
S: Send + Sync,
|
||||
B: Send,
|
||||
{
|
||||
type Rejection = AuthError;
|
||||
|
||||
@@ -63,7 +63,7 @@ pub struct ValidatedForm<T>(pub T);
|
||||
impl<T, S, B> FromRequest<S, B> for ValidatedForm<T>
|
||||
where
|
||||
T: DeserializeOwned + Validate,
|
||||
S: Send,
|
||||
S: Send + Sync,
|
||||
B: http_body::Body + Send,
|
||||
B::Data: Send,
|
||||
B::Error: Into<BoxError>,
|
||||
|
||||
@@ -51,7 +51,7 @@ enum Version {
|
||||
impl<S, B> FromRequest<S, B> for Version
|
||||
where
|
||||
B: Send,
|
||||
S: Send,
|
||||
S: Send + Sync,
|
||||
{
|
||||
type Rejection = Response;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user