refactor: rename traits and generic types
This commit is contained in:
26
src/lib.rs
26
src/lib.rs
@@ -157,12 +157,12 @@ impl<Arguments> ValidationContext<Arguments> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Arguement store
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// `T`: data type to validate
|
/// `T`: data type to validate
|
||||||
/// `Self::A`: dependent arguments
|
/// `Self::A`: dependent arguments
|
||||||
///
|
///
|
||||||
pub trait ArgumentsStore<'a, T> {
|
pub trait Arguments<'a, T> {
|
||||||
/// Argument type
|
/// Argument type
|
||||||
type A: 'a;
|
type A: 'a;
|
||||||
/// Get dependent arguments
|
/// Get dependent arguments
|
||||||
@@ -269,23 +269,22 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<State, Body, Extractor, Store> FromRequest<State, Body> for ValidEx<Extractor, Store>
|
impl<State, Body, Extractor, Args> FromRequest<State, Body> for ValidEx<Extractor, Args>
|
||||||
where
|
where
|
||||||
State: Send + Sync,
|
State: Send + Sync,
|
||||||
Body: Send + Sync + 'static,
|
Body: Send + Sync + 'static,
|
||||||
Store:
|
Args: Send + Sync + for<'a> Arguments<'a, <Extractor as HasValidateArgs<'a>>::ValidateArgs>,
|
||||||
Send + Sync + for<'a> ArgumentsStore<'a, <Extractor as HasValidateArgs<'a>>::ValidateArgs>,
|
|
||||||
Extractor: for<'v> HasValidateArgs<'v> + FromRequest<State, Body>,
|
Extractor: for<'v> HasValidateArgs<'v> + FromRequest<State, Body>,
|
||||||
for<'v> <Extractor as HasValidateArgs<'v>>::ValidateArgs: ValidateArgs<
|
for<'v> <Extractor as HasValidateArgs<'v>>::ValidateArgs: ValidateArgs<
|
||||||
'v,
|
'v,
|
||||||
Args = <Store as ArgumentsStore<'v, <Extractor as HasValidateArgs<'v>>::ValidateArgs>>::A,
|
Args = <Args as Arguments<'v, <Extractor as HasValidateArgs<'v>>::ValidateArgs>>::A,
|
||||||
>,
|
>,
|
||||||
ValidationContext<Store>: FromRef<State>,
|
ValidationContext<Args>: FromRef<State>,
|
||||||
{
|
{
|
||||||
type Rejection = ValidRejection<<Extractor as FromRequest<State, Body>>::Rejection>;
|
type Rejection = ValidRejection<<Extractor as FromRequest<State, Body>>::Rejection>;
|
||||||
|
|
||||||
async fn from_request(req: Request<Body>, state: &State) -> Result<Self, Self::Rejection> {
|
async fn from_request(req: Request<Body>, state: &State) -> Result<Self, Self::Rejection> {
|
||||||
let ValidationContext { arguments }: ValidationContext<Store> = FromRef::from_ref(state);
|
let ValidationContext { arguments }: ValidationContext<Args> = FromRef::from_ref(state);
|
||||||
let inner = Extractor::from_request(req, state)
|
let inner = Extractor::from_request(req, state)
|
||||||
.await
|
.await
|
||||||
.map_err(ValidRejection::Inner)?;
|
.map_err(ValidRejection::Inner)?;
|
||||||
@@ -296,22 +295,21 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<State, Extractor, Store> FromRequestParts<State> for ValidEx<Extractor, Store>
|
impl<State, Extractor, Args> FromRequestParts<State> for ValidEx<Extractor, Args>
|
||||||
where
|
where
|
||||||
State: Send + Sync,
|
State: Send + Sync,
|
||||||
Store:
|
Args: Send + Sync + for<'a> Arguments<'a, <Extractor as HasValidateArgs<'a>>::ValidateArgs>,
|
||||||
Send + Sync + for<'a> ArgumentsStore<'a, <Extractor as HasValidateArgs<'a>>::ValidateArgs>,
|
|
||||||
Extractor: for<'v> HasValidateArgs<'v> + FromRequestParts<State>,
|
Extractor: for<'v> HasValidateArgs<'v> + FromRequestParts<State>,
|
||||||
for<'v> <Extractor as HasValidateArgs<'v>>::ValidateArgs: ValidateArgs<
|
for<'v> <Extractor as HasValidateArgs<'v>>::ValidateArgs: ValidateArgs<
|
||||||
'v,
|
'v,
|
||||||
Args = <Store as ArgumentsStore<'v, <Extractor as HasValidateArgs<'v>>::ValidateArgs>>::A,
|
Args = <Args as Arguments<'v, <Extractor as HasValidateArgs<'v>>::ValidateArgs>>::A,
|
||||||
>,
|
>,
|
||||||
ValidationContext<Store>: FromRef<State>,
|
ValidationContext<Args>: FromRef<State>,
|
||||||
{
|
{
|
||||||
type Rejection = ValidRejection<<Extractor as FromRequestParts<State>>::Rejection>;
|
type Rejection = ValidRejection<<Extractor as FromRequestParts<State>>::Rejection>;
|
||||||
|
|
||||||
async fn from_request_parts(parts: &mut Parts, state: &State) -> Result<Self, Self::Rejection> {
|
async fn from_request_parts(parts: &mut Parts, state: &State) -> Result<Self, Self::Rejection> {
|
||||||
let ValidationContext { arguments }: ValidationContext<Store> = FromRef::from_ref(state);
|
let ValidationContext { arguments }: ValidationContext<Args> = FromRef::from_ref(state);
|
||||||
let inner = Extractor::from_request_parts(parts, state)
|
let inner = Extractor::from_request_parts(parts, state)
|
||||||
.await
|
.await
|
||||||
.map_err(ValidRejection::Inner)?;
|
.map_err(ValidRejection::Inner)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user