# `PhoenixWebTransport.Lanes`
[🔗](https://github.com/knevan/phoenix-wtransport/blob/main/lib/phoenix_wtransport/lanes.ex#L1)

Lane bookkeeping shared between `LaneSerializer`, `SessionEngine`, and
`Quic.Session`.

A push from the Phoenix socket is one of:
  * `{:text | :binary, iodata}` (or list of pushes) routed to control lane `0`
  * A lane container (`"L"` or causal-barrier `"B"`) produced by
    `PhoenixWebTransport.LaneSerializer`
  * `{:datagram, iodata}` or `{:datagram, :text | :binary, iodata}` for
    opt-in RFC 9297 unreliable datagrams

# `lane_frame`

```elixir
@type lane_frame() ::
  {non_neg_integer(), {:text | :binary, binary()}}
  | {:barrier, 0, {:text, binary()}, [pos_integer()]}
  | {:datagram, {:text | :binary, binary()}}
```

# `push`

```elixir
@type push() ::
  {:text | :binary, iodata()}
  | {:datagram, iodata()}
  | {:datagram, :text | :binary, iodata()}
```

# `control`

```elixir
@spec control() :: non_neg_integer()
```

The control lane id.

# `decode_datagram`

```elixir
@spec decode_datagram(binary()) :: {:text | :binary, binary()}
```

Decodes a typed datagram payload.

# `encode_barrier`

```elixir
@spec encode_barrier(%{optional(non_neg_integer()) =&gt; pos_integer()}, binary()) ::
  binary()
```

Wraps a control lane JSON payload with a causal barrier wait map
`%{slot => expected_seq}` as `["__wt_barrier", wait_map, original_json]`.

# `encode_datagram`

```elixir
@spec encode_datagram(:text | :binary, binary()) :: binary()
```

Encodes a typed datagram payload with a 1-byte type tag (`0` text, `1` binary).

# `frames_for_push`

```elixir
@spec frames_for_push(push()) :: [lane_frame()]
```

Turns a single socket push into normalized lane frames.

# `frames_for_pushes`

```elixir
@spec frames_for_pushes(push() | [push()]) :: [lane_frame()]
```

Turns one push or a list of pushes into normalized lane frames.

# `slot_for`

```elixir
@spec slot_for(non_neg_integer(), pos_integer()) :: non_neg_integer()
```

Maps a lane onto one of `max_lanes` stream slots. Lane 0 keeps its own
stream; component lanes share the remaining slots round-robin.

# `urgency`

```elixir
@spec urgency(non_neg_integer()) :: 1..7
```

Shortest message first on the RFC 9218 urgency scale (0 most urgent, 7
least; erlang_quic reserves 0 for its own control streams).

---

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