ModBoss.Encoding.Metadata (modboss v0.2.0)

Copy Markdown View Source

Metadata to support encoding and decoding.

Passed as the second argument to encode and decode functions that accept 2-arity (e.g. encode_foo/2, decode_foo/2). Contains information about the mapping being encoded/decoded and any user-provided context.

Fields

  • :name — the mapping name (e.g. :outdoor_temp)
  • :type — the object type (e.g. :holding_register)
  • :address_count — the number of addresses in the mapping
  • :context — user-provided context map, passed via the :context option on ModBoss.read/4, ModBoss.write/4, or ModBoss.encode/3. Defaults to %{}.

For example, when encoding ASCII text, address_count tells you how many registers to pad into. See the implementation of ModBoss.Encoding.encode_ascii/2 for an example.

Summary

Types

t()

@type t() :: %ModBoss.Encoding.Metadata{
  address_count: ModBoss.Mapping.count(),
  context: map(),
  name: ModBoss.Mapping.name(),
  type: ModBoss.Mapping.object_type()
}