Data serialization using bitstream