TomlTranscoder

class TomlTranscoder(encoder: TomlEncoder, decoder: TomlDecoder)

A bidirectional TOML transcoder, capable of converting TomlValues into Kotlin values, and vice versa.

A transcoder is intended to make your life easier by keeping custom mappings in sync between your encoder and decoder. Unless you need custom en/decoder functions, using a transcoder instead of a separate encoder and decoder is highly recommended.

Constructors

TomlTranscoder
Link copied to clipboard
fun TomlTranscoder(encoder: TomlEncoder, decoder: TomlDecoder)

Types

Companion
Link copied to clipboard
object Companion

Functions

decode
Link copied to clipboard
inline fun <T> decode(value: TomlValue): T

Decode the given TomlValue into the type represented by the given type parameter.

encode
Link copied to clipboard
fun encode(value: Any): TomlValue

Encode the given value into a TomlValue using the receiver TomlTranscoder.

withMapping
Link copied to clipboard
inline fun <T : Any> withMapping(vararg mapping: Pair<TomlName, KotlinName>): TomlTranscoder

Returns a copy of the receiver TOML transcoder, extended with a custom property mapping for the type T. Mappings are given on the form "tomlName" to "kotlinName".

fun <T : Any> withMapping(kClass: KClass<T>, vararg mapping: Pair<TomlName, KotlinName>): TomlTranscoder

Returns a copy of the receiver TOML transcoder, extended with a custom property mapping for the type represented by the given KClass. Mappings are given on the form "tomlName" to "kotlinName".

Properties

decoder
Link copied to clipboard
val decoder: TomlDecoder

Decoder half of the transcoder. The inverse of encoder.

encoder
Link copied to clipboard
val encoder: TomlEncoder

Encoder half of the transcoder. The inverse of decoder.