Generate encoders for array types from slices, arrays, and
iterator-generating functions. Note that because we need to consume the
iterator and we may need to iterate multiple times for measurement before
serialization, we implement encoding for a function returning an iterator.
A buffer that accumulates bytes of sized structs and feeds them to provided sink function when messages
are complete. This buffer handles partial messages and multiple messages in a single push.