Swatch
Opaque message moving between peers. The wire layer does not interpret the bytes; that is the consumer's job.
sender and sequence are filled in by the transport when the frame is received; senders leave them unset (null sender, zero sequence) and the local Seam stamps them on dispatch.
Encapsulated offset-view
Internally a Swatch is backed by a (ByteArray, offset, length) triple so that header-stripping in MuxSeam and NamedMux creates a zero-copy view via dropFirst. The backing array never escapes publicly — there is no accessor that returns the live backing array. All copies are explicit and named:
toByteArray — always allocates; the only way to obtain a
ByteArray.decode — hands the backing array directly to BinaryFormat.decodeFromByteArray for full-array frames (zero-copy); copies only for sub-views (unavoidable, same cost as toByteArray).
decodeToString — zero-copy slice decode via ByteArray.decodeToString.
byteAt / payloadSize — zero-copy indexed access.
equals and hashCode compare the logical slice, so a dropFirst view equals a freshly-constructed Swatch of the same bytes.
Construction
Pass a ByteArray to the primary constructor. The Swatch takes ownership of that array — callers must not mutate it after construction.
Functions
Decodes the logical payload bytes as a UTF-8 string without allocating an intermediate ByteArray (uses ByteArray.decodeToString over the internal slice).
Returns a copy of the logical payload as a fresh ByteArray.