Interface StructFieldType<T>

StructBuilder field type.

interface StructFieldType<T> {
    asString?: ((this: void, value: T) => string);
    decode: ((this: void, tlv: Tlv) => T);
    encode: ((this: void, value: T) => Encodable | typeof OmitEmpty);
    newValue: ((this: void) => T);
}

Type Parameters

  • T

    Value type.

Properties

asString?: ((this: void, value: T) => string)

Print a value as string representation.

`${value}`

Invoked by TLV class .toString method. If the field is optional and unset, this is not invoked. If the field is repeatable, this is invoked once per element.

decode: ((this: void, tlv: Tlv) => T)

Decode a value from sub-TLV element.

Invoked by TLV class .decodeFrom method. If the field is repeatable, this is invoked once per sub-TLV element.

encode: ((this: void, value: T) => Encodable | typeof OmitEmpty)

Encode a value to sub-TLV element.

Type declaration

Invoked by TLV class .encodeTo method. If the field is optional and unset, this is not invoked. If the field is repeatable, this is invoked once per element.

newValue: ((this: void) => T)

Create a new value of type T.

Invoked by the TLV class constructor on each non-repeatable required field.