unsafeTransformTarget

inline fun <Source : Any, Target : Any, Target2 : Any> Codec<Source, Target>.unsafeTransformTarget(crossinline from: (Target2) -> Target, crossinline to: (Target) -> Target2): Codec<Source, Target2>(source)

Builds a new codec by transforming the encoded target type.

Return

a codec that delegates through from and to for encoding and decoding respectively.

Parameters

Source

domain type handled by the original codec.

Target

serialized type emitted by the original codec.

Target2

alternative serialized type emitted by the returned codec.

from

transformation that converts Target2 into the original Target prior to decoding.

to

transformation that converts the encoded Target into Target2.

See also