Codec
Complete codec: encodes, decodes, and detects frame boundaries.
Implementors override exactly two methods — the context-aware versions:
decode with DecodeContext
encode with EncodeContext
The context-free overloads inherited from Encoder and Decoder delegate to the context versions with DecodeContext.Empty / EncodeContext.Empty, so callers that don't need context work transparently.
Simple codecs that don't use context just ignore the context parameter.
Functions
Link copied to clipboard
fun <T> Codec<T>.encodeToBuffer(value: T, factory: BufferFactory = BufferFactory.Default, context: EncodeContext = EncodeContext.Empty): ReadBuffer
Link copied to clipboard
Link copied to clipboard
Estimates the encoded size of value for buffer pre-allocation.
Link copied to clipboard
fun <T> Codec<T>.testRoundTrip(value: T, expectedBytes: ByteArray? = null, factory: BufferFactory = BufferFactory.Default, decodeContext: DecodeContext = DecodeContext.Empty, encodeContext: EncodeContext = EncodeContext.Empty): T
Testing utility: encodes value, optionally verifies the wire bytes match expectedBytes, then decodes and returns the result. Intended for use in test suites to validate codec correctness.