Skip to content

Discriminated[D: (Equatable[D] val & Stringable val), Msg: Any val]

[Source]

Tagged union dispatch: a discriminator codec selects which variant codec to use.

On decode, reads the discriminator and dispatches to the matching variant codec. On encode, tests each variant's narrowing function to find a match, then writes the discriminator followed by the variant body.

Built via DiscriminatedBuilder — not constructed directly.

class val Discriminated[D: (Equatable[D] val & Stringable val), Msg: Any val] is
  Codec[Msg] val

Implements


Public Functions

decode

[Source]

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

Parameters

Returns


encode

[Source]

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

Parameters

  • value: Msg

Returns