sizeOfMessage function
Calculates the encoded byte size of message without producing output.
This is used when encoding length-prefixed submessages: the parent needs to know the byte length before writing the length prefix.
Implementation
int sizeOfMessage(
Map<String, Object?> message,
List<Map<String, Object?>> descriptor,
) {
// The simplest correct implementation: marshal to bytes and measure length.
// This avoids duplicating all the size-calculation logic for every type.
return marshal(message, descriptor).length;
}