Amarula.Protocol.Binary.Node (amarula v0.1.0)

View Source

Binary node structure for WhatsApp protocol.

Represents a node in the WhatsApp binary protocol tree structure. Each node has a tag, attributes, and content.

Summary

Functions

Gets the number of child nodes.

Creates a new node with the given tag, attributes, and content. This is an alias for new/3 for compatibility with the messages module.

Checks if the node has no content.

Gets a child node by index.

Checks if the node has binary content.

Checks if a node has children (nested nodes).

Checks if the node has string content.

Creates a new node with the given tag, attributes, and content.

Types

t()

@type t() :: %Amarula.Protocol.Binary.Node{
  attrs: map() | [{binary(), binary()}],
  content: binary() | [t()] | nil,
  tag: binary()
}

Functions

child_count(arg1)

@spec child_count(t()) :: non_neg_integer()

Gets the number of child nodes.

create(tag, attrs \\ %{}, content \\ nil)

@spec create(binary(), map(), binary() | [t()] | nil) :: t()

Creates a new node with the given tag, attributes, and content. This is an alias for new/3 for compatibility with the messages module.

empty?(arg1)

@spec empty?(t()) :: boolean()

Checks if the node has no content.

get_child(arg1, index)

@spec get_child(t(), non_neg_integer()) :: t() | nil

Gets a child node by index.

has_binary_content?(arg1)

@spec has_binary_content?(t()) :: boolean()

Checks if the node has binary content.

has_children?(arg1)

@spec has_children?(t()) :: boolean()

Checks if a node has children (nested nodes).

has_string_content?(arg1)

@spec has_string_content?(t()) :: boolean()

Checks if the node has string content.

new(tag, attrs \\ %{}, content \\ nil)

@spec new(binary(), map(), binary() | [t()] | nil) :: t()

Creates a new node with the given tag, attributes, and content.

Examples

iex> Node.new("iq", %{id: "1"}, nil)
%Node{tag: "iq", attrs: %{id: "1"}, content: nil}

iex> Node.new("message", %{}, "Hello")
%Node{tag: "message", attrs: %{}, content: "Hello"}