Description
Currently, I have to put the endianness and bit width for integer fields into my encoder and decoder.
This is suboptimal because it gets spread over two places (encoder and decoder), and I have to write extra code for this.
It would be fantastic if msgspec supported annotations for bit width and endianness. This way, I could do something like:
class Payload(Struct):
idx: Annotated[int, length=4, byteorder="little"]
number: Annotated[int, length=8, byteorder="big"]
p = Payload(idx=1, number=42)
assert msgspec.msgpack.decode(msgspec.msgpack.encode(p)) == p # pure magic
Thanks for considering!
Description
Currently, I have to put the endianness and bit width for integer fields into my encoder and decoder.
This is suboptimal because it gets spread over two places (encoder and decoder), and I have to write extra code for this.
It would be fantastic if
msgspecsupported annotations for bit width and endianness. This way, I could do something like:Thanks for considering!