CodecContext

interface CodecContext

Base interface for typed key-value context that flows through codec chains.

Keys defined on CodecContext are accessible in both DecodeContext and EncodeContext, useful for shared configuration like protocol version or byte order.

data object VersionKey : CodecContext.Key<Int>()

// Works in both directions
val dCtx = DecodeContext.Empty.with(VersionKey, 2)
val eCtx = EncodeContext.Empty.with(VersionKey, 2)

Inheritors

Types

Link copied to clipboard
abstract class Key<T : Any>

A typed key for storing values in a CodecContext.

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.