Skip to content

Make default packing configurable #60

@lexmag

Description

@lexmag

The idea is to support :packer option in pack/2 that defaults to Msgpax.Packer.
This way any default packing can be overwritten with:

defmodule MyPacker do
  use Msgpax.Packer

  def pack(value) when is_float(value) do
    # pack into 32-bit format
  end
end

Where use Msgpax.Packer expands to @behaviour Msgpax.Packer and also defines the @before_compile callback that should inject Msgpax.Packer.pack for catch-all clause.

We still need to think how to efficiently pass the user-provided packer into Msgpax.Packer for usage when unpacking collections.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions