Helper types and functions for working with the decoded form of application
tags ({:null, nil}, {:unsigned_integer, 42}, {:constructed, {tag, value, len}}, etc.).
Most users interact with these structures indirectly through the service ACKs and property-value machinery. This module exists so that code that does need to pattern-match on raw encodings has a convenient place for types and small utilities.
Summary
Types
Valid create options. For a description on each option, see create/2.
List of create options.
Represents application tags encoding with a slightly more enjoyable structure.
Functions
Creates a struct from the application tags encoding.
Bang version of create/2.
Reverses the process and brings it back to its raw form.
Bang version of to_encoding/1.
Types
@type create_option() :: {:cast_type, BACnet.Protocol.ApplicationTags.primitive_type()} | {:context, any()} | {:encoder, (any() -> {:ok, any()} | {:error, any()} | any())}
Valid create options. For a description on each option, see create/2.
@type create_options() :: [create_option()]
List of create options.
@type t() :: %BACnet.Protocol.ApplicationTags.Encoding{ encoding: :primitive | :tagged | :constructed, extras: Keyword.t(), type: BACnet.Protocol.ApplicationTags.primitive_type() | nil, value: term() }
Represents application tags encoding with a slightly more enjoyable structure.
For tagged and constructed encodings, the extras contains :tag_number.
Extras may also contain :context and :encoder, if passed to create/2.
Functions
@spec create(BACnet.Protocol.ApplicationTags.encoding(), create_options()) :: {:ok, t()} | {:error, term()}
Creates a struct from the application tags encoding.
Tagged encodings can be optionally casted to primitive types.
Available options:
cast_type: ApplicationTags.primitive_type()- Optional. Casts the tagged encoding to the primitive type.context: any()- Optional. A user-defined value for matching by the user, untouched by the module.encoder: (any() -> {:ok, any()} | {:error, any()} | any())- Optional. An encoder function to use on the value, before creating the application tags encoding.
@spec create!(BACnet.Protocol.ApplicationTags.encoding(), create_options()) :: t() | no_return()
Bang version of create/2.
@spec to_encoding(t()) :: {:ok, BACnet.Protocol.ApplicationTags.encoding()} | {:error, term()}
Reverses the process and brings it back to its raw form.
@spec to_encoding!(t()) :: BACnet.Protocol.ApplicationTags.encoding() | no_return()
Bang version of to_encoding/1.