Union is a dynamic-size type.
Serializing a union has two steps:
Serialize a item type id in bytes as a 32 bit unsigned integer in little-endian. The item type id is the index of the inner items, and it's starting at 0.
Serialize the inner item.
Type Parameters
T extends Record<string, BytesCodec>
Parameters
itemCodec: T
the union item record
fields: (keyof T)[]
the list of itemCodec's keys. It's also provide an order for pack/unpack.
Union is a dynamic-size type. Serializing a union has two steps: