Skip to content

Literal

[Source]

Match or emit a fixed byte sequence.

On decode, the bytes at the current position must match exactly or MalformedData is returned. On encode, the fixed bytes are emitted. The decoded value is None — literals carry no data.

class val Literal is
  Codec[None val] val

Implements


Constructors

create

[Source]

new val create(
  expected: Array[U8 val] val)
: Literal val^

Parameters

Returns


Public Functions

decode

[Source]

Decode the expected byte sequence, returning None on match.

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

Parameters

Returns


encode

[Source]

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

Parameters

Returns