Companion

Factory helpers for common Codec construction patterns.

Functions

Link copied to clipboard
inline fun <T : Any> identity(name: String): Codec<T, T>

Builds a codec that forwards values without transforming them.

Link copied to clipboard
inline fun <I : Any, O : Any> nullable(name: String, crossinline encoder: (I) -> O, crossinline decoder: (O) -> I?): Codec<I, O>

Builds a codec around a decoder that reports failure by returning null.

Link copied to clipboard
inline fun <I : Any, O : Any> unsafe(name: String, crossinline encoder: (I) -> O, crossinline decoder: (O) -> I): Codec<I, O>

Builds a codec around a decoder that may throw while parsing.