Open 0xpr03 opened 5 years ago
How would tower-web pick the variant to extract to?
Not sure whether I get this right but I was expecting to receive the value back like when using serde and then match over that.
So I can do something like this:
#[post("/post-type")]
fn post_type(&self, body: InstanceType) -> Result<MyResponse, ()> {
println!("Body: {:?}", body);
match body {
A(v) => ...
B(v) => ...
}
}
Ah! I see, yeah i think that makes sense.
I think you can work around this by doing:
#[derive(Extract)]
struct ExtractInstance(InstantType);
#[derive(Deserialize)]
enum InstanceType {
/// ....
}
Yes that works and is fine for my case as I start from a struct and have an enum as child value. Wasn't aware that you can just use "Deserialize" at the child types instead of Extract.
I'm going to leave the issue open as the original snippet should be made to work.
Thanks for the report.
When trying to do an Extract for a enum I'm getting "not yet implemented" errors:
Throws
It works as long as I don't try to mark the enum as Extract. I've tried to find similar issues.