IP.sigil_i
You're seeing just the macro
sigil_i
, go back to IP module for more information.
Specs
allows you to use the convenient ~i sigil to declare an IP address in its normal string form, instead of using the tuple form.
iex> import IP
iex> ~i"10.0.0.1"
{10, 0, 0, 1}
also works for cidr-form subnet blocks
iex> import IP
iex> ~i"10.0.0.0/24"
%IP.Subnet{routing_prefix: {10, 0, 0, 0}, bit_length: 24}
and generic IP ranges
iex> import IP
iex> ~i"10.0.0.3..10.0.0.7"
%IP.Range{first: {10, 0, 0, 3}, last: {10, 0, 0, 7}}
and socket addresses:
iex> import IP
iex> ~i"10.0.0.1:1234"
%IP.SockAddr{family: :inet, port: 1234, addr: {10, 0, 0, 1}}
and ip/subnet combinations for configuration:
iex> import IP
iex> ~i"10.0.0.4/24"config
{{10, 0, 0, 4}, %IP.Subnet{routing_prefix: {10, 0, 0, 0}, bit_length: 24}}
You can also use ~i
for ip addresses and subnets with the m
suffix
in the context of matches.
iex> import IP
iex> fn -> ~i"10.0.x.3"m = {10, 0, 1, 3}; x end.()
1