DNS.Message.Record.Data.Behaviour behaviour (DNS v0.5.0)

View Source

Behaviour for DNS record data implementations.

This module defines the interface that all DNS record data implementations must follow. Implementations should implement the DNS.Parameter and String.Chars protocols as well.

Summary

Callbacks

Parse record data from binary format.

Create a new record data instance from the given raw data. The raw data format varies by record type.

Get the length of the record data in binary format.

Return the DNS record type code for this implementation.

Validate the record data structure and content.

Types

raw_data()

@type raw_data() :: term()

t()

@type t() :: struct()

Callbacks

from_iodata(binary, arg2)

@callback from_iodata(binary(), binary() | nil) :: t()

Parse record data from binary format.

new(raw_data)

@callback new(raw_data()) :: t()

Create a new record data instance from the given raw data. The raw data format varies by record type.

rdlength(t)

@callback rdlength(t()) :: non_neg_integer()

Get the length of the record data in binary format.

record_type()

@callback record_type() :: non_neg_integer()

Return the DNS record type code for this implementation.

validate(t)

(optional)
@callback validate(t()) :: :ok | {:error, term()}

Validate the record data structure and content.