getMapEncoder
Call Signature
Returns an encoder for maps.
This encoder serializes maps where the keys and values are encoded
using the provided key and value encoders. The number of entries
is determined by the size configuration.
For more details, see getMapCodec.
Type Parameters
| Type Parameter | Description |
|---|---|
TFromKey | The type of the keys before encoding. |
TFromValue | The type of the values before encoding. |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | Encoder<TFromKey> | The encoder for the map's keys. |
value | Encoder<TFromValue> | The encoder for the map's values. |
config | MapCodecConfig<NumberEncoder> & object | Configuration options for encoding the map. |
Returns
FixedSizeEncoder<Map<TFromKey, TFromValue>, 0>
A FixedSizeEncoder or VariableSizeEncoder for encoding maps.
Example
Encoding a map with a u32 size prefix.
See
Call Signature
Returns an encoder for maps.
This encoder serializes maps where the keys and values are encoded
using the provided key and value encoders. The number of entries
is determined by the size configuration.
For more details, see getMapCodec.
Type Parameters
| Type Parameter | Description |
|---|---|
TFromKey | The type of the keys before encoding. |
TFromValue | The type of the values before encoding. |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | FixedSizeEncoder<TFromKey> | The encoder for the map's keys. |
value | FixedSizeEncoder<TFromValue> | The encoder for the map's values. |
config | MapCodecConfig<NumberEncoder> & object | Configuration options for encoding the map. |
Returns
FixedSizeEncoder<Map<TFromKey, TFromValue>>
A FixedSizeEncoder or VariableSizeEncoder for encoding maps.
Example
Encoding a map with a u32 size prefix.
See
Call Signature
Returns an encoder for maps.
This encoder serializes maps where the keys and values are encoded
using the provided key and value encoders. The number of entries
is determined by the size configuration.
For more details, see getMapCodec.
Type Parameters
| Type Parameter | Description |
|---|---|
TFromKey | The type of the keys before encoding. |
TFromValue | The type of the values before encoding. |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | Encoder<TFromKey> | The encoder for the map's keys. |
value | Encoder<TFromValue> | The encoder for the map's values. |
config? | MapCodecConfig<NumberEncoder> | Configuration options for encoding the map. |
Returns
VariableSizeEncoder<Map<TFromKey, TFromValue>>
A FixedSizeEncoder or VariableSizeEncoder for encoding maps.
Example
Encoding a map with a u32 size prefix.