Mapping

trait Mapping[L, H]

A bi-directional mapping between values of type L and values of type H.

Low-level values of type L can be decoded to a higher-level value of type H. The decoding can fail; this is represented by a result of type DecodeResult.Failure. Failures might occur due to format errors, wrong arity, exceptions, or validation errors. Validators can be added through the validate method.

High-level values of type H can be encoded as a low-level value of type L.

Mappings can be chained using one of the map functions.

Type parameters:
H

The type of the high-level value.

L

The type of the low-level value.

Companion:
object
class Object
trait Matchable
class Any
Mapping[L, H]

Value members

Abstract methods

def encode(h: H): L
def rawDecode(l: L): DecodeResult[H]

Concrete methods

def decode(l: L): DecodeResult[H]
  • calls rawDecode
  • catches any exceptions that might occur, converting them to decode failures
  • validates the result
def map[HH](codec: Mapping[H, HH]): Mapping[L, HH]
def validate(v: Validator[H]): Mapping[L, H]