mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-08 00:00:24 +02:00
Replace async_trait with AFIT / RPITIT (#2308)
Co-authored-by: Jonas Platte <[email protected]>
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::{Extension, FromRequestParts},
|
||||
};
|
||||
use axum::extract::{Extension, FromRequestParts};
|
||||
use http::request::Parts;
|
||||
|
||||
/// Cache results of other extractors.
|
||||
@@ -19,7 +16,6 @@ use http::request::Parts;
|
||||
/// ```rust
|
||||
/// use axum_extra::extract::Cached;
|
||||
/// use axum::{
|
||||
/// async_trait,
|
||||
/// extract::FromRequestParts,
|
||||
/// response::{IntoResponse, Response},
|
||||
/// http::{StatusCode, request::Parts},
|
||||
@@ -28,7 +24,6 @@ use http::request::Parts;
|
||||
/// #[derive(Clone)]
|
||||
/// struct Session { /* ... */ }
|
||||
///
|
||||
/// #[async_trait]
|
||||
/// impl<S> FromRequestParts<S> for Session
|
||||
/// where
|
||||
/// S: Send + Sync,
|
||||
@@ -43,7 +38,6 @@ use http::request::Parts;
|
||||
///
|
||||
/// struct CurrentUser { /* ... */ }
|
||||
///
|
||||
/// #[async_trait]
|
||||
/// impl<S> FromRequestParts<S> for CurrentUser
|
||||
/// where
|
||||
/// S: Send + Sync,
|
||||
@@ -86,7 +80,6 @@ pub struct Cached<T>(pub T);
|
||||
#[derive(Clone)]
|
||||
struct CachedEntry<T>(T);
|
||||
|
||||
#[async_trait]
|
||||
impl<S, T> FromRequestParts<S> for Cached<T>
|
||||
where
|
||||
S: Send + Sync,
|
||||
@@ -125,7 +118,6 @@ mod tests {
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
struct Extractor(Instant);
|
||||
|
||||
#[async_trait]
|
||||
impl<S> FromRequestParts<S> for Extractor
|
||||
where
|
||||
S: Send + Sync,
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
//! See [`CookieJar`], [`SignedCookieJar`], and [`PrivateCookieJar`] for more details.
|
||||
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::FromRequestParts,
|
||||
response::{IntoResponse, IntoResponseParts, Response, ResponseParts},
|
||||
};
|
||||
@@ -90,7 +89,6 @@ pub struct CookieJar {
|
||||
jar: cookie::CookieJar,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<S> FromRequestParts<S> for CookieJar
|
||||
where
|
||||
S: Send + Sync,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use super::{cookies_from_request, set_cookies, Cookie, Key};
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::{FromRef, FromRequestParts},
|
||||
response::{IntoResponse, IntoResponseParts, Response, ResponseParts},
|
||||
};
|
||||
@@ -122,7 +121,6 @@ impl<K> fmt::Debug for PrivateCookieJar<K> {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<S, K> FromRequestParts<S> for PrivateCookieJar<K>
|
||||
where
|
||||
S: Send + Sync,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use super::{cookies_from_request, set_cookies};
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::{FromRef, FromRequestParts},
|
||||
response::{IntoResponse, IntoResponseParts, Response, ResponseParts},
|
||||
};
|
||||
@@ -139,7 +138,6 @@ impl<K> fmt::Debug for SignedCookieJar<K> {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<S, K> FromRequestParts<S> for SignedCookieJar<K>
|
||||
where
|
||||
S: Send + Sync,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::{rejection::RawFormRejection, FromRequest, RawForm, Request},
|
||||
response::{IntoResponse, Response},
|
||||
Error, RequestExt,
|
||||
@@ -44,7 +43,6 @@ pub struct Form<T>(pub T);
|
||||
|
||||
axum_core::__impl_deref!(Form);
|
||||
|
||||
#[async_trait]
|
||||
impl<T, S> FromRequest<S> for Form<T>
|
||||
where
|
||||
T: DeserializeOwned,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use axum::async_trait;
|
||||
use axum::extract::{FromRequest, Request};
|
||||
use axum_core::__composite_rejection as composite_rejection;
|
||||
use axum_core::__define_rejection as define_rejection;
|
||||
@@ -84,7 +83,6 @@ pub struct JsonDeserializer<T> {
|
||||
_marker: PhantomData<T>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<T, S> FromRequest<S> for JsonDeserializer<T>
|
||||
where
|
||||
T: Deserialize<'static>,
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
//! See [`Multipart`] for more details.
|
||||
|
||||
use axum::{
|
||||
async_trait,
|
||||
body::{Body, Bytes},
|
||||
extract::FromRequest,
|
||||
response::{IntoResponse, Response},
|
||||
@@ -90,7 +89,6 @@ pub struct Multipart {
|
||||
inner: multer::Multipart<'static>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<S> FromRequest<S> for Multipart
|
||||
where
|
||||
S: Send + Sync,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::{path::ErrorKind, rejection::PathRejection, FromRequestParts, Path},
|
||||
RequestPartsExt,
|
||||
};
|
||||
@@ -35,7 +34,6 @@ use serde::de::DeserializeOwned;
|
||||
#[derive(Debug)]
|
||||
pub struct OptionalPath<T>(pub Option<T>);
|
||||
|
||||
#[async_trait]
|
||||
impl<T, S> FromRequestParts<S> for OptionalPath<T>
|
||||
where
|
||||
T: DeserializeOwned + Send + 'static,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::FromRequestParts,
|
||||
response::{IntoResponse, Response},
|
||||
Error,
|
||||
@@ -82,7 +81,6 @@ use std::fmt;
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct Query<T>(pub T);
|
||||
|
||||
#[async_trait]
|
||||
impl<T, S> FromRequestParts<S> for Query<T>
|
||||
where
|
||||
T: DeserializeOwned,
|
||||
@@ -187,7 +185,6 @@ impl std::error::Error for QueryRejection {
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct OptionalQuery<T>(pub Option<T>);
|
||||
|
||||
#[async_trait]
|
||||
impl<T, S> FromRequestParts<S> for OptionalQuery<T>
|
||||
where
|
||||
T: DeserializeOwned,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use axum::async_trait;
|
||||
use axum::extract::{FromRequest, FromRequestParts, Request};
|
||||
use axum::response::IntoResponse;
|
||||
use http::request::Parts;
|
||||
@@ -110,7 +109,6 @@ impl<E, R> DerefMut for WithRejection<E, R> {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<E, R, S> FromRequest<S> for WithRejection<E, R>
|
||||
where
|
||||
S: Send + Sync,
|
||||
@@ -125,7 +123,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<E, R, S> FromRequestParts<S> for WithRejection<E, R>
|
||||
where
|
||||
S: Send + Sync,
|
||||
@@ -169,7 +166,6 @@ mod tests {
|
||||
struct TestExtractor;
|
||||
struct TestRejection;
|
||||
|
||||
#[async_trait]
|
||||
impl<S> FromRequestParts<S> for TestExtractor
|
||||
where
|
||||
S: Send + Sync,
|
||||
|
||||
Reference in New Issue
Block a user