# `Linx.IP`
[🔗](https://github.com/oshlabs/linx/blob/v0.2.0/lib/linx/ip.ex#L1)

An IPv4 or IPv6 address.

## Construction

    iex> Linx.IP.parse("10.0.0.5")
    {:ok, ~IP"10.0.0.5"}

    iex> Linx.IP.parse("fc00::1")
    {:ok, ~IP"fc00::1"}

## The `~IP` sigil

`import Linx.IP` and build addresses (or subnets, when the literal
contains `/`) at compile time:

    iex> import Linx.IP
    iex> ~IP"10.0.0.5"
    ~IP"10.0.0.5"
    iex> ~IP"10.0.0.0/24"
    ~IP"10.0.0.0/24"

Invalid input raises at compile time, so a bad literal can never reach the
kernel.

## Inspect

An IP renders as the same sigil that would build it — `~IP"10.0.0.5"` —
so iex output round-trips back into source code.

## Wire codec

`encode/1` and `decode/1` are the `Linx.Netlink.Codec` entry points: a
`Linx.IP` serializes to its raw bytes (4 for IPv4, 16 for IPv6), and the
family is recovered on decode from the byte length.

# `family`

```elixir
@type family() :: :inet | :inet6
```

# `t`

```elixir
@type t() :: %Linx.IP{bytes: binary(), family: family()}
```

# `parse`

```elixir
@spec parse(binary()) :: {:ok, t()} | {:error, term()}
```

Parses a string into an `Linx.IP` — IPv4 or IPv6.

# `sigil_IP`
*macro* 

The `~IP` sigil: builds an `Linx.IP` (or `Linx.IP.Subnet` if the literal
contains `/`) at compile time. Invalid input raises `ArgumentError`.

# `to_string`

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

Renders an `Linx.IP` as a string — dotted-quad for IPv4, canonical
compressed for IPv6 (`fc00::1`, not `fc00:0:0:0:0:0:0:1`).

---

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