vE5li / korangar

A Vulkan based Ragnarok Online client
MIT License
139 stars 32 forks source link

Add Serialize/Deserialize trait bounds to `ragnarok_packets::Packet` #81

Open vE5li opened 3 months ago

vE5li commented 3 months ago

There is currently no use case for this but I can imagine something like converting the packets to JSON for debugging or data collection, and there is really no reason the packets shouldn't implement Serde traits.

This ticket is pretty easy, just a bit of manual labor (much less when using a good Regex I assume).

aleDsz commented 3 months ago

I can see this being used to communicate with RO using WebSocket (jokes) 😆

arpd commented 2 months ago

I don't think this is quite as simple as suggested.

serde only supports arrays of up to [_; 32]. In other words, any arrays with N > 32 means defining a new struct that implements Serialize, Deserialize, in addition to e.g.:

As an example, see ragnarok_packets/lib.rs::struct CharacterSelectionPacket and CharacterServerInformation.

Still a good issue, but you probably want some familiarity with serde before tackling it.

vE5li commented 2 months ago

Good point!

To be honest I thought serde would have moved to using const generics by now. I will link an issue providing a possible solution and an explainiation as to why it's a problem in the first place.