Pack and unpack structures to/from Buffers