Constructing Serializers

By this point you should be able to:

  • Parse the send-tables and extract the fields.
  • Parse a field's type
  • Determine the layout of a field
  • Create a field decoder for a given field type.

The next goal is to create a minimal representation of these fields so they can be referenced efficiently.

As stated before, serializers contain an array of fields, which during updates are referenced by indices. We need to map fields to their decoder or nested serializers while keeping the correct field layout. These fields need to be in the same order as they arrive in the send-tables.

We will combine the field layout and the field decoder into a single type called Field.

Representation of a Field

Each field layout can be boiled down to a few simple parameters:

Value

ParameterTypeDescription
decoderfield_decoderthe decoder for this value

FixedArray

ParameterTypeDescription
decoderfield_decoderthe decoder for the values in this array
countintthe size of this array (fixed)

VariableArray

ParameterTypeDescription
inner_decoderfield_decoderthe decoder for the values in this array

FixedTable

ParameterTypeDescription
serializer*serializerthe serializer of the nested table

VariableTable

ParameterTypeDescription
serializer*serializerthe serializer of the nested table(s)

PolyTable

ParameterTypeDescription
serializers[]*serializerthe serializers of the nested table types

Constructing Fields