ChrisBuchholz/accord

Explore possibility for better Rocket support

ChrisBuchholz opened this issue · 2 comments

Being able to derive support for FromForm for Validated<T> where T: Accord + Validated and FromData would make Rocket integration much simpler.

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).

Great suggestion. I will explore this.