BitwiseIp.Block.parse-exclamation-mark
You're seeing just the function
parse-exclamation-mark, go back to BitwiseIp.Block module for more information.
Specs
An error-raising variant of parse/1.
This function parses strings in CIDR
notation,
where an IP address is followed by a prefix length composed of a slash (/)
and a decimal number of leading bits in the subnet mask. The prefix length is
optional. If missing, it defaults to the full width of the IP address: 32
bits for IPv4, 128 for IPv6.
The constituent parts are parsed using BitwiseIp.parse/1 and
BitwiseIp.Mask.parse/2. The address has the mask applied before
constructing the BitwiseIp.Block struct, thereby discarding any lower bits.
If the string is invalid, this function raises an ArgumentError.
BitwiseIp.Block implements the String.Chars protocol, so parsing can be
undone using to_string/1.
Examples
iex> BitwiseIp.Block.parse!("192.168.0.0/16")
%BitwiseIp.Block{proto: :v4, addr: 3232235520, mask: 4294901760}
iex> BitwiseIp.Block.parse!("fc00::/8")
%BitwiseIp.Block{proto: :v6, addr: 334965454937798799971759379190646833152, mask: 338953138925153547590470800371487866880}
iex> BitwiseIp.Block.parse!("256.0.0.0/8")
** (ArgumentError) Invalid IP address "256.0.0.0" in CIDR "256.0.0.0/8"
iex> BitwiseIp.Block.parse!("dead::beef/129")
** (ArgumentError) Invalid IPv6 mask "129" in CIDR "dead::beef/129"
iex> BitwiseIp.Block.parse!("192.168.0.0/8") |> to_string()
"192.0.0.0/8"
iex> BitwiseIp.Block.parse!("::") |> to_string()
"::/128"