Skip to content

Class: TupleField ​

Represents a single field in a Tuple, storing a value as a UTF-8 encoded byte array.

Used for path segments or protocol fields in MOQT.

Constructors ​

Constructor ​

new TupleField(value): TupleField

The raw value of the field as a byte array.

Parameters ​

value ​

Uint8Array

Returns ​

TupleField

Properties ​

value ​

readonly value: Uint8Array

Methods ​

serialize() ​

serialize(): Uint8Array

Serializes this field to a length-prefixed byte array.

Returns ​

Uint8Array

The serialized bytes.


toUtf8() ​

toUtf8(): string

Decodes the field value to a UTF-8 string.

Returns ​

string

The decoded string.


deserialize() ​

static deserialize(buf): TupleField

Deserializes a TupleField from a buffer.

Parameters ​

buf ​

BaseByteBuffer

The buffer to read from.

Returns ​

TupleField

The deserialized TupleField.

Throws ​

CastingError if the length cannot be safely cast to number.

Throws ​

NotEnoughBytesError if buffer does not contain enough bytes.


fromUtf8() ​

static fromUtf8(str): TupleField

Creates a TupleField from a UTF-8 string.

Parameters ​

str ​

string

The string to encode.

Returns ​

TupleField

A new TupleField containing the encoded value.