getSetCodec
Call Signature
Returns a codec for encoding and decoding sets of items.
This codec serializes Set<T> values by encoding each item using the provided item codec.
The number of items is stored as a prefix using a u32 codec by default.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
TFrom | - | The type of the items in the set before encoding. |
TTo | TFrom | The type of the items in the set after decoding. |
Parameters
| Parameter | Type | Description |
|---|---|---|
item | Codec<TFrom, TTo> | The codec to use for each set item. |
config | SetCodecConfig<NumberCodec> & object | Optional configuration specifying the size strategy. |
Returns
FixedSizeCodec<Set<TFrom>, Set<TTo>, 0>
A Codec<Set<TFrom>, Set<TTo>> for encoding and decoding sets.
Examples
Encoding and decoding a set of u8 numbers.
Using a u16 prefix for size.
Using a fixed-size set.
Using remainder to infer set size.
Remarks
Separate getSetEncoder and getSetDecoder functions are available.
See
Call Signature
Returns a codec for encoding and decoding sets of items.
This codec serializes Set<T> values by encoding each item using the provided item codec.
The number of items is stored as a prefix using a u32 codec by default.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
TFrom | - | The type of the items in the set before encoding. |
TTo | TFrom | The type of the items in the set after decoding. |
Parameters
| Parameter | Type | Description |
|---|---|---|
item | FixedSizeCodec<TFrom, TTo> | The codec to use for each set item. |
config | SetCodecConfig<NumberCodec> & object | Optional configuration specifying the size strategy. |
Returns
FixedSizeCodec<Set<TFrom>, Set<TTo>>
A Codec<Set<TFrom>, Set<TTo>> for encoding and decoding sets.
Examples
Encoding and decoding a set of u8 numbers.
Using a u16 prefix for size.
Using a fixed-size set.
Using remainder to infer set size.
Remarks
Separate getSetEncoder and getSetDecoder functions are available.
See
Call Signature
Returns a codec for encoding and decoding sets of items.
This codec serializes Set<T> values by encoding each item using the provided item codec.
The number of items is stored as a prefix using a u32 codec by default.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
TFrom | - | The type of the items in the set before encoding. |
TTo | TFrom | The type of the items in the set after decoding. |
Parameters
| Parameter | Type | Description |
|---|---|---|
item | Codec<TFrom, TTo> | The codec to use for each set item. |
config? | SetCodecConfig<NumberCodec> | Optional configuration specifying the size strategy. |
Returns
VariableSizeCodec<Set<TFrom>, Set<TTo>>
A Codec<Set<TFrom>, Set<TTo>> for encoding and decoding sets.
Examples
Encoding and decoding a set of u8 numbers.
Using a u16 prefix for size.
Using a fixed-size set.
Using remainder to infer set size.
Remarks
Separate getSetEncoder and getSetDecoder functions are available.