kencode

EncodedFormat

open class EncodedFormat(val configuration: EncodedConfiguration) : StringFormat(source)

Text StringFormat that produces short, predictable string tokens by composing:

  1. A binary format (e.g. PackedFormat, ProtoBuf).

  2. An optional PayloadTransform (CompactZeros, checksum, encryption, ECC, …).

  3. An ASCII-safe byte encoding (e.g. Base62, Base64, Base36, Base85).

Typical use:

  • encodeToString: serialize -> transform.encode -> encode bytes to text.

  • decodeFromString: decode text to bytes -> transform.decode -> deserialize.

Use the EncodedFormat builder function to create a customized instance.

Inheritors

Constructors

Link copied to clipboard
constructor(configuration: EncodedConfiguration)
constructor(codec: ByteEncoding = Base62, transform: PayloadTransform? = null, binaryFormat: BinaryFormat = PackedFormat)

Secondary constructor for direct instantiation without the builder.

Types

Link copied to clipboard

Default format: PackedFormat + Base62, no transform.

Properties

Link copied to clipboard

The active configuration dictating the codec, transform, and binary format.

Link copied to clipboard
open override val serializersModule: SerializersModule

Delegates to the underlying BinaryFormat's serializers module.

Functions

Link copied to clipboard
open override fun <T> decodeFromString(deserializer: DeserializationStrategy<T>, string: String): T

Decodes string using the text codec, applies the inverse transform, then deserializes with the configured binary format.

Link copied to clipboard
open override fun <T> encodeToString(serializer: SerializationStrategy<T>, value: T): String

Serializes value with the configured binary format, applies the transform, and encodes the resulting byte array using the text codec.

EncodedFormat

constructor(configuration: EncodedConfiguration)(source)


constructor(codec: ByteEncoding = Base62, transform: PayloadTransform? = null, binaryFormat: BinaryFormat = PackedFormat)(source)

Secondary constructor for direct instantiation without the builder.

configuration

decodeFromString

open override fun <T> decodeFromString(deserializer: DeserializationStrategy<T>, string: String): T(source)

Decodes string using the text codec, applies the inverse transform, then deserializes with the configured binary format.

Throws

if the transform's decode step fails (e.g. checksum mismatch).

encodeToString

open override fun <T> encodeToString(serializer: SerializationStrategy<T>, value: T): String(source)

Serializes value with the configured binary format, applies the transform, and encodes the resulting byte array using the text codec.

serializersModule

open override val serializersModule: SerializersModule(source)

Delegates to the underlying BinaryFormat's serializers module.