unsafeTransformSource

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

Builds a new codec by transforming the decoded source type.

Return

a codec that delegates encoding/decoding through from and to.

Parameters

Source

domain type handled by the original codec.

Target

serialized type emitted by the original codec.

Source2

alternative domain type exposed by the returned codec.

from

transformation that maps the decoded Source value to Source2.

to

transformation that maps the incoming Source2 value back to Source.

See also