I have to write some code that is going to be using an ad-hoc defined encodings a lot. Like: "File starts with a "file header" that is 2 bytes of magic number, 1 bytes of some id, 4 bytes of allocated size". "TcpStream has a one byte of command, then depending on the command 2 bytes of this, or 8 bytes of that". The rawest, crudest of raw encoding, most stuff fixed sized or size-prefixed. I started writing it by hand, but pretty quickly realized that this is not very idiomatic way.
Any recommendations for approaches to take here? Any crate that could do it?