A bi-directional mapping between low-level values of type L
and high-level values of type H
. Low level values are formatted as CF
.
The mapping consists of a pair of functions, one to decode (L => H
), and one to encode (H => L
) Decoding can fail, and this is
represented as a result of type DecodeResult.
A codec also contains optional meta-data on the schema
of the high-level value, as well as an instance of the format (which determines
the media type of the low-level value).
Codec instances are used as implicit values, and are looked up when defining endpoint inputs/outputs. Depending on a particular endpoint input/output, it might require a codec which uses a specific format, or a specific low-level value.
Codec instances can be derived basing on other values (e.g. such as json encoders/decoders when integrating with json libraries). Or, they can be defined by hand for custom types, usually customising an existing, simpler codec.
Codecs can be chained with Mapping s using the map
function.
- Type parameters:
- CF
The format of encoded values. Corresponds to the media type.
- H
The type of the high-level value.
- L
The type of the low-level value.
- Companion:
- object
Value members
Abstract methods
Concrete methods
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result
- calls
rawDecode
- catches any exceptions that might occur, converting them to decode failures
- validates the result