View Source BlueHeron.HCI.ArrayedData (blue_heron v0.5.1)

Serialization functions for arrayed data.

Arrayed parameters are specified using the following notation: ParameterA[i]. If more than one set of arrayed parameters are specified (e.g. ParameterA[i], ParameterB[i]), then, unless noted otherwise, the order of the parameters are as follows: ParameterA[0], ParameterB[0], ParameterA[1], ParameterB[1], ParameterA[2], ParameterB[2], ... ParameterA[n], ParameterB[n]

Reference: Version 5.0, Vol 2, Part E, 5.2

Both serialize/2 and deserialize/4 rely on a schema to function. A schema is a keyword list where each key is a field and each value shall be:

  • a positive integer when denoting the size in bits of the field
  • a three-tuple when the field itself represents the length of a subsequent variable length field
  • an atom when the field is variable length and a preceding field represents its length

For example if length_data itself was 8 bits and represented the length of data that would be written as:

[
  length_data: {:variable, :data, 8},
  data: :length_data
]

Summary

Functions

Deserialize the binary representation of a list of structs according to schema.

Serializes a list of structs into their binary representation according to schema.

Types

field()

@type field() :: atom()

field_size()

@type field_size() :: pos_integer() | {:variable, atom(), pos_integer()} | atom()

schema()

@type schema() :: [{field(), field_size()}, ...]

Functions

deserialize(schema, length, struct_module, bin)

Deserialize the binary representation of a list of structs according to schema.

serialize(schema, structs)

Serializes a list of structs into their binary representation according to schema.