# `NodeWire.Protocol`
[🔗](https://github.com/c2bw/nodewire/blob/v0.1.0/lib/node_wire/protocol.ex#L1)

Compile-time declarations of immutable, versioned message protocols.

    defmodule MyApp.Wire do
      use NodeWire.Protocol,
        id: "myapp.agent", version: 1, codec: :json,
        capabilities: ["echo.v1"]

      message :echo, id: 1
    end

Required options are `:id` (a family identifier up to 128 bytes), `:version`
(1..65535), and `:codec` (`:json` or `:erlang_term`). `:capabilities` defaults
to an empty list, with at most 32 unique identifiers of at most 64 bytes.
Identifiers begin with a lowercase ASCII letter and contain only lowercase
letters, digits, periods, underscores and hyphens. Declare at least one
message with a unique atom name and numeric ID in 1..65535.

Incompatible message changes require a new version. All configured modules
must belong to one family and have distinct versions; at most eight versions
may be configured on an endpoint.

Generated modules expose `protocol_id/0`, `version/0`, `codec/0`, `codec_name/0`,
`capabilities/0`, `message_types/0`, `encode/1` and `decode/1`. Encode/decode
operate on inner NodeWire frames, excluding the TLS packet length prefix.
They return `{:error, :invalid_payload}` for invalid payloads/frames and do not
enforce session phases, endpoint packet limits or handler domain validation.

# `codec`

```elixir
@type codec() :: :json | :erlang_term
```

# `message`
*macro* 

Declares an application message atom with a unique `:id` in 1..65535.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
