Explore possibility for better Rocket support
ChrisBuchholz opened this issue · 2 comments
ChrisBuchholz commented
Being able to derive support for FromForm for Validated<T> where T: Accord + Validated
and FromData
would make Rocket integration much simpler.
SergioBenitez commented
In particular, I should be able to used my Accord
type as a target of data
. One way to do this is to have a type, let's call it ValidJson
, defined as struct ValidJson<T: Accord + Deserialize>(T)
, which then allows me to do:
#[post("/something", data = "<valid_thing>")]
fn add_something(valid_thing: ValidJson<Thing>) -> T { ... }
Another type, ValidForm
, could do the same for forms: struct ValidForm<T: Accord + FromForm>(T)
.
ChrisBuchholz commented
Great suggestion. I will explore this.