ExWapp.Message.Handler.Wire.Fields (ExWapp v0.1.2)

Copy Markdown View Source

Pure protobuf wire-field primitives, independent of the generated protos.

This module knows wire types, varints, fixed-width numbers, and length-delimited fields. It has no knowledge of WhatsApp message kinds.

Production decoding now goes through the generated WAWebProtobufs* modules; these primitives remain as the second, independent reader that the wire-format tests use to pin the exact bytes we put on (and read off) the wire.

Summary

Functions

Returns every length-delimited value for a field in decoded order.

Returns a protobuf boolean field value or nil.

Returns a binary field value or nil.

Collects every length-delimited value in a protobuf payload.

Decodes all supported protobuf fields without raising.

Returns a fixed64 double field value or nil.

Finds a length-delimited field directly in a protobuf payload.

Finds the first length-delimited value in an already-decoded field list.

Finds the first varint value in an already-decoded field list.

Returns a fixed32 float field value or nil.

Returns a varint field value or nil.

Types

wire_field()

@type wire_field() :: {non_neg_integer(), 0 | 1 | 2 | 5, term()}

Functions

all_length_delimited(fields, field_num)

@spec all_length_delimited([wire_field()], non_neg_integer()) :: [binary()]

Returns every length-delimited value for a field in decoded order.

bool(payload, field)

@spec bool(binary(), non_neg_integer()) :: boolean() | nil

Returns a protobuf boolean field value or nil.

bytes(payload, field)

@spec bytes(binary(), non_neg_integer()) :: binary() | nil

Returns a binary field value or nil.

collect_length_delimited_values(binary)

@spec collect_length_delimited_values(binary()) ::
  {:ok, [binary()]} | {:error, term()}

Collects every length-delimited value in a protobuf payload.

decode_safe(binary)

@spec decode_safe(binary()) :: {:ok, [wire_field()]} | {:error, term()}

Decodes all supported protobuf fields without raising.

double(payload, field)

@spec double(binary(), non_neg_integer()) :: float() | nil

Returns a fixed64 double field value or nil.

find_length_delimited(binary, field_num)

@spec find_length_delimited(binary(), non_neg_integer()) ::
  {:ok, binary()} | {:error, term()}

Finds a length-delimited field directly in a protobuf payload.

first_length_delimited(fields, field_num)

@spec first_length_delimited([wire_field()], non_neg_integer()) :: binary() | nil

Finds the first length-delimited value in an already-decoded field list.

first_varint(fields, field_num)

@spec first_varint([wire_field()], non_neg_integer()) :: integer() | nil

Finds the first varint value in an already-decoded field list.

float(payload, field)

@spec float(binary(), non_neg_integer()) :: float() | nil

Returns a fixed32 float field value or nil.

varint(payload, wanted_field)

@spec varint(binary(), non_neg_integer()) :: integer() | nil

Returns a varint field value or nil.