Skip to main content

Class: Struct<T>

A type that represents a structure of multiple fields. Similar to an object in JavaScript.

Type Parameters​

Type ParameterDescription

T

The type of the structure where each key is a field name and the value is the type of the field.

Implements​

Constructors​

new Struct()​

new Struct<T>(entries: StructTypes<T>): Struct<T>

Creates a new structure type.

Parameters​

ParameterTypeDescription

entries

StructTypes<T>

The entries of the structure where each key is a field name and the value is the type of the field.

Returns​

Struct<T>

Defined in​

types/struct.ts:25

Methods​

write()​

write(writer: ByteStreamWriter, value: T): void

Writes the structure to the buffer.

Parameters​

ParameterTypeDescription

writer

ByteStreamWriter

The buffer writer.

value

T

The structure to write.

Returns​

void

Implementation of​

Schema.write

Defined in​

types/struct.ts:34


read()​

read(reader: ByteStreamReader): T

Reads the structure from the buffer.

Parameters​

ParameterTypeDescription

reader

ByteStreamReader

The buffer reader.

Returns​

T

The structure read from the buffer.

Implementation of​

Schema.read

Defined in​

types/struct.ts:45