EncodeContext

Context passed to Codec.encode for runtime configuration during encoding.

Use this to pass compression levels, wire format versions, or other caller-supplied options through the codec chain.

val ctx = EncodeContext.Empty
.with(CompressionKey, CompressionLevel.BestSpeed)

MyCodec.encode(buffer, value, ctx)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract operator fun <T : Any> get(key: CodecContext.Key<T>): T?

Returns the value associated with key, or null if not present.

Link copied to clipboard
abstract fun <T : Any> with(key: CodecContext.Key<T>, value: T): EncodeContext

Returns a new EncodeContext with key set to value. Does not modify this context — contexts are immutable.