encodeFrame

fun encodeFrame(payload: ByteArray, maxFrameSize: Int = DEFAULT_MAX_FRAME_SIZE): ByteArray

Encode payload as [len_be32][payload] — a 4-byte big-endian length prefix followed by the payload bytes. Byte-identical to what :kuilt-stream's framed() writes via sink.writeInt(frame.size), so the two framings are wire-compatible.

Throws FrameTooLargeException before allocating the output array if payload exceeds maxFrameSize.