BitwiseIp.decode
You're seeing just the function
decode
, go back to BitwiseIp module for more information.
Specs
decode(v4()) :: :inet.ip4_address()
decode(v6()) :: :inet.ip6_address()
Decodes a bitwise IP into an :inet
-style tuple.
The Erlang standard library represents IP addresses as tuples of integers: 4
octet values for IPv4, 8 hextet values for IPv6. This function decodes the
single number from a BitwiseIp
struct into its constituent parts. This can
be undone with encode/1
.
Beware of redundant usage in performance-critical paths. Because of the overhead in decoding the integer, excessive translation back & forth between the formats may outweigh any benefits gained from other operations on the single-integer representation.
Examples
iex> BitwiseIp.decode(%BitwiseIp{proto: :v4, addr: 2130706433})
{127, 0, 0, 1}
iex> BitwiseIp.decode(%BitwiseIp{proto: :v6, addr: 1})
{0, 0, 0, 0, 0, 0, 0, 1}