Currently, deser does not support deserialization in object variants.
I think to implement it is like a serde, but without externally tagged (because it can be done without object variants.) and may be adjacently tagged - https://serde.rs/enum-representations.html
How I see tagged:
type
MessageEnum = enum
Request, Response
Message = object
id: string
case kind {.rename("type").}: MessageEnum
of Request:
`method`: string
params: Params
of Response:
result: Value
const js = """
{
"type": "Request",
"id": "123",
"method": "321",
"params": {...}
}
"""
let msg = js.parse().to(Message)
assert msg.kind == Request
How i see untagged:
##[
`untagged` is not for the entire object, because an object can have multiple "cases" with different behaviors.
`deser` tries to match data with each case, the first successfully matched one will be returned, and the `kind` field will be assigned the corresponding value.
]##
type
MessageEnum = enum
Request, Response
Message = object
id: string
case kind {.untagged.}: MessageEnum
of Request:
`method`: string
params: Params
of Response:
result: Value
const js = """
{
"id": "123",
"method": "321",
"params": {...}
}
"""
let msg = js.parse().to(Message)
assert msg.kind == Request
Blocked by:
5 - Right now, deser doesn't know if any field is missing or not. The error handling should help with this. Of course, exception handling should only be generated in the case of untagged.
Currently,
deser
does not support deserialization in object variants. I think to implement it is like aserde
, but without externally tagged (because it can be done without object variants.) and may be adjacently tagged - https://serde.rs/enum-representations.htmlHow I see tagged:
How i see untagged:
Blocked by:
5 - Right now,
deser
doesn't know if any field is missing or not. The error handling should help with this. Of course, exception handling should only be generated in the case of untagged.