getNullableEncoder
Call Signature
Returns an encoder for optional values, allowing null
values to be encoded.
This encoder serializes an optional value using a configurable approach:
- By default, a
u8
prefix is used (0 =null
, 1 = present). This can be customized or disabled. - If
noneValue: 'zeroes'
is set,null
values are encoded as zeroes. - If
noneValue
is a byte array,null
values are replaced with the provided constant.
For more details, see getNullableCodec.
Type Parameters
Type Parameter | Description |
---|---|
TFrom | The type of the main value being encoded. |
TSize extends number | - |
Parameters
Parameter | Type | Description |
---|---|---|
item | FixedSizeEncoder <TFrom , TSize > | The encoder for the value that may be present. |
config | NullableCodecConfig <NumberEncoder > & object | Configuration options for encoding optional values. |
Returns
FixedSizeEncoder
<null
| TFrom
, TSize
>
A FixedSizeEncoder
or VariableSizeEncoder
for encoding nullable values.
Example
Encoding an optional number.
See
Call Signature
Returns an encoder for optional values, allowing null
values to be encoded.
This encoder serializes an optional value using a configurable approach:
- By default, a
u8
prefix is used (0 =null
, 1 = present). This can be customized or disabled. - If
noneValue: 'zeroes'
is set,null
values are encoded as zeroes. - If
noneValue
is a byte array,null
values are replaced with the provided constant.
For more details, see getNullableCodec.
Type Parameters
Type Parameter | Description |
---|---|
TFrom | The type of the main value being encoded. |
Parameters
Parameter | Type | Description |
---|---|---|
item | FixedSizeEncoder <TFrom > | The encoder for the value that may be present. |
config | NullableCodecConfig <FixedSizeNumberEncoder > & object | Configuration options for encoding optional values. |
Returns
FixedSizeEncoder
<null
| TFrom
>
A FixedSizeEncoder
or VariableSizeEncoder
for encoding nullable values.
Example
Encoding an optional number.
See
Call Signature
Returns an encoder for optional values, allowing null
values to be encoded.
This encoder serializes an optional value using a configurable approach:
- By default, a
u8
prefix is used (0 =null
, 1 = present). This can be customized or disabled. - If
noneValue: 'zeroes'
is set,null
values are encoded as zeroes. - If
noneValue
is a byte array,null
values are replaced with the provided constant.
For more details, see getNullableCodec.
Type Parameters
Type Parameter | Description |
---|---|
TFrom | The type of the main value being encoded. |
Parameters
Parameter | Type | Description |
---|---|---|
item | FixedSizeEncoder <TFrom > | The encoder for the value that may be present. |
config | NullableCodecConfig <NumberEncoder > & object | Configuration options for encoding optional values. |
Returns
VariableSizeEncoder
<null
| TFrom
>
A FixedSizeEncoder
or VariableSizeEncoder
for encoding nullable values.
Example
Encoding an optional number.
See
Call Signature
Returns an encoder for optional values, allowing null
values to be encoded.
This encoder serializes an optional value using a configurable approach:
- By default, a
u8
prefix is used (0 =null
, 1 = present). This can be customized or disabled. - If
noneValue: 'zeroes'
is set,null
values are encoded as zeroes. - If
noneValue
is a byte array,null
values are replaced with the provided constant.
For more details, see getNullableCodec.
Type Parameters
Type Parameter | Description |
---|---|
TFrom | The type of the main value being encoded. |
Parameters
Parameter | Type | Description |
---|---|---|
item | Encoder <TFrom > | The encoder for the value that may be present. |
config? | NullableCodecConfig <NumberEncoder > & object | Configuration options for encoding optional values. |
Returns
VariableSizeEncoder
<null
| TFrom
>
A FixedSizeEncoder
or VariableSizeEncoder
for encoding nullable values.
Example
Encoding an optional number.