SetCodecConfig
Defines the configuration options for set codecs.
This configuration allows specifying how the size of the set is encoded.
The size option can be:
- A NumberCodec, NumberEncoder, or NumberDecoder to store the size as a prefix.
- A fixed number of items, enforcing a strict length.
- The string
'remainder'to infer the set size from the remaining bytes (only for fixed-size items). - An ArrayLikeCodecSentinelSize object to end the set when the bytes at the next item position match a constant sentinel.
Type Parameters
| Type Parameter | Description |
|---|---|
TPrefix extends | NumberCodec | NumberDecoder | NumberEncoder | The type used for encoding the size of the set. |
Properties
requireSizePrefix?
Whether a size prefix must be present when decoding.
By default, when the size is stored as a prefix and there are no bytes left to read,
the decoder returns an empty set instead of failing. This allows new collections to be
appended to existing data layouts without breaking the decoding of older data.
Set this option to true to throw when the size prefix is missing.
Only applies when the size option is a number codec.
Default Value
false
size?
The size encoding strategy for the set.
Default Value
Uses a u32 prefix.