ArrayCodecConfig
Defines the configuration options for array codecs.
Type Parameters
| Type Parameter | Description |
|---|---|
TPrefix extends | NumberCodec | NumberDecoder | NumberEncoder | A number codec, decoder, or encoder used for size prefixing. |
Properties
description?
An optional description for the codec, that will be used in error messages.
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 array 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?
Specifies how the size of the array is determined.
- A NumberCodec, NumberDecoder, or NumberEncoder stores a size prefix before encoding the array.
- A
numberenforces a fixed number of elements. "remainder"uses all remaining bytes to infer the array length (only for fixed-size items).- An ArrayLikeCodecSentinelSize object ends the array when the bytes at the next item position match a constant sentinel.
Default Value
A u32 size prefix.