Codec[A: Any val]¶
A bidirectional codec that decodes bytes into a value and encodes a value into bytes.
Codecs are val — immutable and shareable across actors. Small codecs
compose into larger ones via combinators like Seq2, Mapped, and
FlatZip.
decode takes an array and a bit offset, returning either the decoded
value paired with the number of bits consumed, or a DecodeError. The
array is val so byte-slice codecs like Bytes can return zero-copy
views via Array.trim.
encode converts a value to bytes, returning either the encoded bytes or
an EncodeError.
Public Functions¶
decode¶
Decode a value from data starting at the given bit offset.
Parameters¶
Returns¶
- ((A , USize val) | DecodeError)
encode¶
Parameters¶
- value: A
Returns¶
- (Array[U8 val] val | EncodeError)