# `Linx.Netlink.Rtnl.Stats.Link64`
[🔗](https://github.com/oshlabs/linx/blob/v0.2.0/lib/linx/netlink/rtnl/stats/link64.ex#L1)

Per-interface counters as the kernel reports them in
`IFLA_STATS_LINK_64` — `struct rtnl_link_stats64`, a packed array of
64-bit counters defined in `include/uapi/linux/if_link.h`.

The struct grew over time. The first 24 counters
(`rx_packets` .. `rx_nohandler`) have been there since the 64-bit
stats were introduced; `rx_otherhost_dropped` was added in Linux 5.19,
so on older kernels its field is `nil`.

This module implements the value-type contract the `Linx.Netlink.Codec`
DSL expects (`encode/1` and `decode/1`). `decode/1` accepts both the
192-byte (24-counter) and 200-byte (25-counter) layouts, and tolerates
extra trailing bytes from a still-newer kernel.

# `counter`

```elixir
@type counter() :: non_neg_integer() | nil
```

# `t`

```elixir
@type t() :: %Linx.Netlink.Rtnl.Stats.Link64{
  collisions: term(),
  multicast: term(),
  rx_bytes: term(),
  rx_compressed: term(),
  rx_crc_errors: term(),
  rx_dropped: term(),
  rx_errors: term(),
  rx_fifo_errors: term(),
  rx_frame_errors: term(),
  rx_length_errors: term(),
  rx_missed_errors: term(),
  rx_nohandler: term(),
  rx_otherhost_dropped: term(),
  rx_over_errors: term(),
  rx_packets: term(),
  tx_aborted_errors: term(),
  tx_bytes: term(),
  tx_carrier_errors: term(),
  tx_compressed: term(),
  tx_dropped: term(),
  tx_errors: term(),
  tx_fifo_errors: term(),
  tx_heartbeat_errors: term(),
  tx_packets: term(),
  tx_window_errors: term()
}
```

# `decode`

```elixir
@spec decode(binary()) :: t()
```

Decodes a packed `rtnl_link_stats64` payload.

Accepts the 24-counter (192-byte) layout from kernels < 5.19, the
25-counter (200-byte) layout from 5.19+, and tolerates extra trailing
bytes from a still-newer kernel. Counters the payload does not carry
remain `nil`.

# `encode`

```elixir
@spec encode(t()) :: binary()
```

Encodes a `t:t/0` into the packed `rtnl_link_stats64` bytes — always
the full 25-counter (200-byte) form; a `nil` counter is written as 0.

---

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