Currently, an enum with a payload (struct or tuple) cannot derive biome_deserialize::Deserializable
.
For instance, the following code don't compile:
#[derive(Deserializable)]
enum Message {
Request { id: String, method: String, params: Params },
Response { id: String, result: Value },
}
We could support this kind of code using the same strategies as serde.
I propose to only support the internally tagged pattern. We could require settings the same attribute as serde:
#[derive(Deserializable, Serialize, Deserialize)]
#[serde(tag = "type")]
#[deserializable(tag = "type")]
enum Message {
Request { id: String, method: String, params: Params },
Response { id: String, result: Value },
}
We could also implement the adjacent tagging pattern. We could require the use of this second pattern for enum with a tuple payload:
#[derive(Deserializable, Serialize, Deserialize)]
#[serde(tag = "type", content = "value")]
#[deserializable(tag = "type", content = "value")]
enum Message {
Request(Request),
Response(Response),
}
NOTE: I am not sure how serde handle enum with tuple payload with the other strategy.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too