OptionCodecConfig
Defines the configuration options for Option codecs.
The getOptionCodec function behaves similarly to getNullableCodec
but encodes Option<T> types instead of T | null types.
This configuration controls how None values are encoded and how presence is determined when decoding.
See
Type Parameters
| Type Parameter | Description |
|---|---|
TPrefix extends NumberCodec | NumberDecoder | NumberEncoder | A number codec, encoder, or decoder used as the presence prefix. |
Properties
noneValue?
Specifies how None values are represented in the encoded data.
- By default, None values are omitted from encoding.
'zeroes': The bytes allocated for the value are filled with zeroes. This requires a fixed-size codec for the item.- Custom byte array: None values are replaced with a predefined byte sequence. This results in a variable-size codec.
Default Value
No explicit noneValue is used; None values are omitted.
prefix?
The presence prefix used to distinguish between None and present values.
- By default, a
u8prefix is used (0 = None,1 = Some). - Custom number codec: Allows defining a different number size for the prefix.
null: No prefix is used;noneValue(if provided) determines None. If nononeValueis set, None is identified by the absence of bytes.
Default Value
u8 prefix.