Skip to content

Mapped[A: Any val, B: Any val]

[Source]

Bidirectional type mapping between a wire type A and a domain type B.

The forward function transforms decoded A values into B values, and may fail (partial) to signal malformed data (e.g., checksum validation). The reverse function transforms B back to A for encoding.

class val Mapped[A: Any val, B: Any val] is
  Codec[B] val

Implements


Constructors

create

[Source]

new val create(
  c: Codec[A] val,
  f: {(A): B ?}[A, B] val,
  r: {(B): A}[A, B] val)
: Mapped[A, B] val^

Parameters

  • c: Codec[A] val
  • f: {(A): B ?}[A, B] val
  • r: {(B): A}[A, B] val

Returns


Public Functions

decode

[Source]

fun box decode(
  data: Array[U8 val] val,
  offset: USize val)
: ((B , USize val) | DecodeError)

Parameters

Returns


encode

[Source]

fun box encode(
  value: B)
: (Array[U8 val] val | EncodeError)

Parameters

  • value: B

Returns