Skip to content

CodecSerializer

open class CodecSerializer<T>(codec: Codec<T>) : KSerializer<T> 

A KSerializer for Codec types using the active KOps implementations.

This is Archie's simpler, opinionated version of the codec-serializer bridge. It supports JSON, TOML, and NBT encoders/decoders out of the box. To convert a Codec to a KSerializer use the serializer extension function.

Archie's SerializerCodec (the reverse direction) supports the same three formats plus CBOR via kotlinx.serialization.cbor.Cbor.

Parameters

  • T: The type managed by the Codec.

  • codec: The Mojang Codec to wrap.

Constructors

CodecSerializer

constructor(codec: Codec<T>)

Parameters

  • T: The type managed by the Codec.

  • codec: The Mojang Codec to wrap.

Properties

descriptor

open override val descriptor: SerialDescriptor

Functions

codec

inline fun <T : Any> codec(): Codec<T>
inline fun <T : Any> KSerializer<T>.codec(): Codec<T>

deserialize

open override fun deserialize(decoder: Decoder): T

getStreamCodec

inline fun <T : Any> KSerializer<T>.getStreamCodec(): StreamCodec<RegistryFriendlyByteBuf, T>

serialize

open override fun serialize(encoder: Encoder, value: T)