Key
A typed key for storing values in a CodecContext.
Keys are compared by identity (reference equality). Define keys as data object or val singletons on your codec object:
object MyCodec : Codec<Foo> {
// Preferred: data object (singleton, IDE-navigable)
data object AllocatorKey : CodecContext.Key<BufferAllocator>()
// Also valid: val with anonymous instance
val MaxSizeKey = object : CodecContext.Key<Int>() {}
}Content copied to clipboard