Interface StructFieldType<T>

StructBuilder field type.

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

Type Parameters

  • T

    Value type.

Properties

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

Print a value as string representation.

Type declaration

    • (this, value): string
    • Parameters

      • this: void
      • value: T

      Returns string

Default Value

`${value}`

Remarks

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, tlv) => T)

Decode a value from sub-TLV element.

Type declaration

    • (this, tlv): T
    • Parameters

      • this: void
      • tlv: Tlv

      Returns T

Remarks

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

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

Encode a value to sub-TLV element.

Type declaration

Returns

TLV-VALUE, or Encoder.OmitEmpty to omit the field.

Remarks

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) => T)

Create a new value of type T.

Type declaration

    • (this): T
    • Parameters

      • this: void

      Returns T

Remarks

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