Type Alias NullableCodecConfig<TPrefix>

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

Defines the config for nullable codecs.

Type Parameters

Type declaration

  • OptionalnoneValue?: ReadonlyUint8Array | "zeroes"

    Defines how the None (or null) value should be represented.

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

    When 'zeroes' is provided, a null 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 null value will be represented by the provided byte array. Note that this returns a variable-size codec since the byte array representing null 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 null. The value 0 is encoded for null 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 null. If no noneValue is provided, then the absence of any bytes is used to determine if the value is null.

    u8 prefix.