getMapCodec
Call Signature
getMapCodec<
TFromKey
,TFromValue
,TToKey
,TToValue
>(key
,value
,config
):FixedSizeCodec
<Map
<TFromKey
,TFromValue
>,Map
<TToKey
,TToValue
>,0
>
Returns a codec for encoding and decoding maps.
This codec serializes maps where the key/value pairs are encoded
and decoded one after another using the provided key and value codecs.
The number of entries is determined by the size
configuration and
defaults to a u32
size prefix.
Type Parameters
Type Parameter | Default type | Description |
---|---|---|
TFromKey | - | The type of the keys before encoding. |
TFromValue | - | The type of the values before encoding. |
TToKey | TFromKey | The type of the keys after decoding. |
TToValue | TFromValue | The type of the values after decoding. |
Parameters
Parameter | Type | Description |
---|---|---|
key | Codec <TFromKey , TToKey > | The codec for the map's keys. |
value | Codec <TFromValue , TToValue > | The codec for the map's values. |
config | MapCodecConfig <NumberCodec > & object | Configuration options for encoding and decoding the map. |
Returns
FixedSizeCodec
<Map
<TFromKey
, TFromValue
>, Map
<TToKey
, TToValue
>, 0
>
A FixedSizeCodec
or VariableSizeCodec
for encoding and decoding maps.
Examples
Encoding and decoding a map with a u32
size prefix (default).
Encoding and decoding a map with a u16
size prefix.
Encoding and decoding a fixed-size map.
Encoding and decoding a map with remainder size.
Remarks
Separate getMapEncoder and getMapDecoder functions are available.
See
Call Signature
getMapCodec<
TFromKey
,TFromValue
,TToKey
,TToValue
>(key
,value
,config
):FixedSizeCodec
<Map
<TFromKey
,TFromValue
>,Map
<TToKey
,TToValue
>>
Returns a codec for encoding and decoding maps.
This codec serializes maps where the key/value pairs are encoded
and decoded one after another using the provided key and value codecs.
The number of entries is determined by the size
configuration and
defaults to a u32
size prefix.
Type Parameters
Type Parameter | Default type | Description |
---|---|---|
TFromKey | - | The type of the keys before encoding. |
TFromValue | - | The type of the values before encoding. |
TToKey | TFromKey | The type of the keys after decoding. |
TToValue | TFromValue | The type of the values after decoding. |
Parameters
Parameter | Type | Description |
---|---|---|
key | FixedSizeCodec <TFromKey , TToKey > | The codec for the map's keys. |
value | FixedSizeCodec <TFromValue , TToValue > | The codec for the map's values. |
config | MapCodecConfig <NumberCodec > & object | Configuration options for encoding and decoding the map. |
Returns
FixedSizeCodec
<Map
<TFromKey
, TFromValue
>, Map
<TToKey
, TToValue
>>
A FixedSizeCodec
or VariableSizeCodec
for encoding and decoding maps.
Examples
Encoding and decoding a map with a u32
size prefix (default).
Encoding and decoding a map with a u16
size prefix.
Encoding and decoding a fixed-size map.
Encoding and decoding a map with remainder size.
Remarks
Separate getMapEncoder and getMapDecoder functions are available.
See
Call Signature
getMapCodec<
TFromKey
,TFromValue
,TToKey
,TToValue
>(key
,value
,config?
):VariableSizeCodec
<Map
<TFromKey
,TFromValue
>,Map
<TToKey
,TToValue
>>
Returns a codec for encoding and decoding maps.
This codec serializes maps where the key/value pairs are encoded
and decoded one after another using the provided key and value codecs.
The number of entries is determined by the size
configuration and
defaults to a u32
size prefix.
Type Parameters
Type Parameter | Default type | Description |
---|---|---|
TFromKey | - | The type of the keys before encoding. |
TFromValue | - | The type of the values before encoding. |
TToKey | TFromKey | The type of the keys after decoding. |
TToValue | TFromValue | The type of the values after decoding. |
Parameters
Parameter | Type | Description |
---|---|---|
key | Codec <TFromKey , TToKey > | The codec for the map's keys. |
value | Codec <TFromValue , TToValue > | The codec for the map's values. |
config? | MapCodecConfig <NumberCodec > | Configuration options for encoding and decoding the map. |
Returns
VariableSizeCodec
<Map
<TFromKey
, TFromValue
>, Map
<TToKey
, TToValue
>>
A FixedSizeCodec
or VariableSizeCodec
for encoding and decoding maps.
Examples
Encoding and decoding a map with a u32
size prefix (default).
Encoding and decoding a map with a u16
size prefix.
Encoding and decoding a fixed-size map.
Encoding and decoding a map with remainder size.
Remarks
Separate getMapEncoder and getMapDecoder functions are available.