# `Dllb.Protocol`
[🔗](https://github.com/Oeditus/dllb_ex/blob/v0.1.0/lib/dllb/protocol.ex#L1)

Encodes queries to dllb wire format and decodes responses.

The dllb protocol is line-based text over TCP: each query is a string
terminated by `\n`, and each response is a JSON (or toon/csv) line
terminated by `\n`.

# `format`

```elixir
@type format() :: :json | :toon | :csv
```

# `decode`

```elixir
@spec decode(String.t(), format()) :: {:ok, map() | String.t()} | {:error, term()}
```

Decodes a response line received from the server.

For `:json` format, parses the line using OTP's built-in `:json` module.
For `:toon` and `:csv`, returns the raw string (trimmed) for now.

Returns `{:ok, parsed}` or `{:error, reason}`.

# `encode`

```elixir
@spec encode(String.t()) :: iodata()
```

Encodes a query string into wire format (iodata) by appending a newline.

# `outcome_command`

```elixir
@spec outcome_command(format()) :: iodata()
```

Returns the `OUTCOME` command to send upon connection to set the response format.

---

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