I have an API here--which I can't change--where {"foo": "bar", "error": ""} is a success and {"error": "nope"} is a failure. My current implementation handles this via
#[derive(Deserialize, Debug)]
struct Response<T> {
#[serde(flatten)]
data: Option<T>,
error: String
}
but this eats deserialization errors in the data part: they become simply Response { data: None, error: "" }. How do I get something more detailed out of it? It'd be nice to end up with a Result<T, String>, hence the title.