Document how unions are encoded
https://capnproto.org/encoding.html
Mentions unions only once:
Unions and groups need not occupy contiguous memory. Indeed, they may have to be split into multiple slots if new fields are added later on.
I may miss something obvious there, but I could not understand from the doc whether unions are encoded as (tag, largest variant) or (tag, every variant...).
I guess the former, because schema spec says:
A union is two or more fields of a struct which are stored in the same location.
But then there is a passage:
You can move an existing field into a new union without breaking compatibility with existing data, as long as all of the other fields in the union are new.
How it is even possible?
Anyway, my point is, mentioning union encoding spec may help.
Source: capnproto/capnproto