I am extremely new at Scala and I'm getting confused by the bit manipulation features. I am hoping someone can point me in the right direction?
I have a byte array defined with the following bit fields:
0-3 - magic number
4 - version
5-7 - payload length in bytes
8-X - payload, of variable length, as indicated in bits 5-7
I would like to serialize this back and forth to a structure such as:
MagicNumber: Integer
Version: Integer
Length: Integer
payload: Array[Byte]
How do you deal with bits in this situation optimally? Most of the examples I've seen deal with higher level serialization, such as JSON. I am trying to serialize and deserialize TCP binary data in this case.