Type Alias OptionCodecConfig<TPrefix>

OptionCodecConfig: {
    noneValue?: ReadonlyUint8Array | "zeroes";
    prefix?: TPrefix | null;
}

Defines the config for Option codecs.

Type Parameters

Type declaration

  • OptionalnoneValue?: ReadonlyUint8Array | "zeroes"

    Defines how the None value should be represented.

    By default, no none value is used. This means a None value will be represented by the absence of the item.

    When 'zeroes' is provided, a None value will skip the bytes that would have been used for the item. Note that this returns a fixed-size codec and thus will only work if the item codec is of fixed size.

    When a custom byte array is provided, a None value will be represented by the provided byte array. Note that this returns a variable-size codec since the byte array representing None does not need to match the size of the item codec.

    No none value is used.
    
  • Optionalprefix?: TPrefix | null

    The codec to use for the boolean prefix, if any.

    By default a u8 number is used as a prefix to determine if the value is None. The value 0 is encoded for None and 1 if the value is present. This can be set to any number codec to customize the prefix.

    When null is provided, no prefix is used and the noneValue is used to determine if the value is None. If no noneValue is provided, then the absence of any bytes is used to determine if the value is None.

    u8 prefix.