Minimal protobuf (proto3) wire-format encoder — varints, tags, and
length-delimited fields. Enough to build the small set of Hedera messages the
SDK needs, with no codegen dependency. (A future milestone may switch to
protoc-generated modules from the canonical Hedera .proto files.)
Summary
Functions
Encode a length-delimited (wire type 2) field: bytes, strings, or sub-messages.
Decode a protobuf message into a list of {field_number, wire_type, value} —
varint values as integers, length-delimited values as binaries. Supports the
wire types this SDK emits (0 and 2) plus 64/32-bit (1 and 5).
Decode a packed run of varints (e.g. a proto3 repeated int64 field body).
First value of field in a decoded message, or nil.
Like bytes_field/2, but emit nothing for nil (proto3 omits unset fields).
Encode a signed sint64 (ZigZag) field — used e.g. for transfer amounts.
Encode a field tag (field number + wire type).
Encode a non-negative integer as a base-128 varint.
Encode a varint (wire type 0) field.
Functions
@spec bytes_field(non_neg_integer(), binary()) :: binary()
Encode a length-delimited (wire type 2) field: bytes, strings, or sub-messages.
@spec decode(binary()) :: [{non_neg_integer(), 0..5, integer() | binary()}]
Decode a protobuf message into a list of {field_number, wire_type, value} —
varint values as integers, length-delimited values as binaries. Supports the
wire types this SDK emits (0 and 2) plus 64/32-bit (1 and 5).
@spec decode_varints(binary()) :: [non_neg_integer()]
Decode a packed run of varints (e.g. a proto3 repeated int64 field body).
@spec field([{non_neg_integer(), 0..5, term()}], non_neg_integer()) :: integer() | binary() | nil
First value of field in a decoded message, or nil.
@spec maybe_bytes_field(non_neg_integer(), binary() | nil) :: binary()
Like bytes_field/2, but emit nothing for nil (proto3 omits unset fields).
@spec sint64_field(non_neg_integer(), integer()) :: binary()
Encode a signed sint64 (ZigZag) field — used e.g. for transfer amounts.
@spec tag(non_neg_integer(), 0..5) :: binary()
Encode a field tag (field number + wire type).
@spec varint(non_neg_integer()) :: binary()
Encode a non-negative integer as a base-128 varint.
@spec varint_field(non_neg_integer(), non_neg_integer()) :: binary()
Encode a varint (wire type 0) field.