I'm trying to write a wrapper around the x11 protocol and I was wondering if theres some better way of interacting with it than manually writing the bytes. I was thinking maybe i could have kotlinx serialization to take some object and convert to bytes, then I could take bytes and convert it into an object. There's the problem though that x11 proto likes to have variable length packets, and sometimes unused bytes which Im not sure how and if thats possible with serialization. Here is a link to the encoding specification
https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#protocol_encoding