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

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
]

Link to this section 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.

Link to this section Types

Specs

field() :: atom()

Specs

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

Specs

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

Link to this section Functions

Link to this function

deserialize(schema, length, struct_module, bin)

View Source

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

Link to this function

serialize(schema, structs)

View Source

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