Ideas for a more powerful `FromRequest(Parts)` derive
Author: hgieselCreated Jul 11, 2026Updated Jul 12, 2026
Feature Request
Motivation
I'd like to derive FromRequestParts from more complex structs (using trait bounds, and where predicates), like:
#[derive(FromRequestParts)]
#[from_request(via(axum::Extension), rejection(MyError))]
pub struct MyType<T1: TX = TTypeX, T2: TY = TTypeY>
where
TX::SubType: XYType<A = T2>,
{
pub field1: T1;
...
}Simply using derive(FromRequestParts) would be nice, because the underlying implementation is still pretty straightforward.
The current version of the macro seems to only support newtypes.
Proposal
It would be nice if we could that kind of macro. Either by modifying, or rather by implementing a new macro that supports this kind of thing
I made a proof of concept (#3833), but it breaks the current usecase with newtypes, where it passes on the nested type rather than the newtype.
Source: tokio-rs/axum