View Source ExSTUN.Message.Attribute behaviour (ex_stun v0.1.0)

Behaviour defining a STUN attribute.

Each module implementing this behaviour is expected to define its own struct that will be passed to to_raw/2.

Link to this section Summary

Callbacks

Deserializes a raw attribute.

Serializes an attribute.

Returns attribute integer type.

Link to this section Callbacks

Link to this callback

from_raw(raw_attribute, message)

View Source (optional)
@callback from_raw(
  raw_attribute :: ExSTUN.Message.RawAttribute.t(),
  message :: ExSTUN.Message.t()
) ::
  {:ok, struct()} | {:error, atom()}

Deserializes a raw attribute.

Message is passed as some of attributes may require transaction id for deserialization.

Link to this callback

to_raw(attribute, message)

View Source (optional)
@callback to_raw(attribute :: struct(), message :: ExSTUN.Message.t()) ::
  ExSTUN.Message.RawAttribute.t()

Serializes an attribute.

Message is passed as some of attributes may require transaction id for serialization.

@callback type() :: integer()

Returns attribute integer type.