OmniBuf.Protobuf (omnibuf v0.1.0)

Copy Markdown View Source

Tier 2: Direct OmniBuf v0.1 serialization and deserialization for standard elixir-protobuf (use Protobuf) message structs using __message_props__/0.

Summary

Functions

Decodes OmniBuf wire bytes into a fresh elixir-protobuf struct of mod (replace mode).

Encodes a standard elixir-protobuf struct into OmniBuf wire bytes. Pass self_describing: true to prepend Field #0 SchemaMeta.

Encodes a standard elixir-protobuf struct into OmniBuf iodata.

Merges OmniBuf wire bytes onto an existing elixir-protobuf struct (merge mode).

Builds an OmniBuf.SchemaMeta from an elixir-protobuf module's __message_props__/0.

Functions

decode(bin, mod)

@spec decode(binary(), module()) :: {:ok, struct()} | {:error, OmniBuf.Error.t()}

Decodes OmniBuf wire bytes into a fresh elixir-protobuf struct of mod (replace mode).

encode(msg, opts \\ [])

@spec encode(struct(), keyword()) :: binary()

Encodes a standard elixir-protobuf struct into OmniBuf wire bytes. Pass self_describing: true to prepend Field #0 SchemaMeta.

encode_iodata(msg, mod, opts \\ [])

@spec encode_iodata(struct(), module(), keyword()) :: iodata()

Encodes a standard elixir-protobuf struct into OmniBuf iodata.

merge(existing, bin)

@spec merge(struct(), binary()) :: {:ok, struct()} | {:error, OmniBuf.Error.t()}

Merges OmniBuf wire bytes onto an existing elixir-protobuf struct (merge mode).

schema_meta(mod, visited \\ MapSet.new())

@spec schema_meta(module(), MapSet.t()) :: OmniBuf.SchemaMeta.t()

Builds an OmniBuf.SchemaMeta from an elixir-protobuf module's __message_props__/0.