Copied from #140 (comment).
I tried using ts-rs in combination with nanoserde but ran into some differences in format. Given a snippet of the code where I'm trying to generate and send a Message.
pub enum Message {
Input(InputEvent)
}
pub enum InputEvent {
Mouse(MouseEvent),
Keyboard(ButtonEvent),
}
pub enum MouseEvent {
Button(ButtonEvent),
Scroll(ScrollEvent),
Move(MoveEvent),
}
pub struct MoveEvent {
pub type_: MovementType,
pub x: i32,
pub y: i32,
}
ts-rs generates what I would expect:
{"Input":{"Mouse":{"Move":{"type_":"Absolute","x":1918,"y":616}}}}
But nanoserde expects (notice the extra array nesting):
{"Input":[{"Mouse":[{"Move":[{"type_":"Absolute","x":0,"y":0}]}]}]}
I also gave serde/serde_json a try and ended up with the expected output:
{"Input":{"Mouse":{"Move":{"type_":"Absolute","x":0,"y":0}}}}
Therefore I am unable to use nanoserde and ts-rs together.
Is it intended that nanoserde do this extra array wrapping?
Copied from #140 (comment).
I tried using
ts-rsin combination withnanoserdebut ran into some differences in format. Given a snippet of the code where I'm trying to generate and send aMessage.ts-rsgenerates what I would expect:{"Input":{"Mouse":{"Move":{"type_":"Absolute","x":1918,"y":616}}}}But
nanoserdeexpects (notice the extra array nesting):{"Input":[{"Mouse":[{"Move":[{"type_":"Absolute","x":0,"y":0}]}]}]}I also gave
serde/serde_jsona try and ended up with the expected output:{"Input":{"Mouse":{"Move":{"type_":"Absolute","x":0,"y":0}}}}Therefore I am unable to use
nanoserdeandts-rstogether.Is it intended that
nanoserdedo this extra array wrapping?