BitwiseIp.Mask.encode

You're seeing just the function encode, go back to BitwiseIp.Mask module for more information.
Link to this function

encode(protocol, prefix)

View Source

Specs

encode(:v4, 0..32) :: integer()
encode(:v6, 0..128) :: integer()

Encodes an integer prefix length as a bitmask.

Given the protocol (either :v4 or :v6) and the number of leading ones in the prefix, this function looks up the corresponding bitmask. The function is only defined on valid prefix lengths: between 0 and 32 for IPv4 and between 0 and 128 for IPv6. To undo this conversion, use decode/2.

Examples

iex> BitwiseIp.Mask.encode(:v4, 12)
4293918720

iex> BitwiseIp.Mask.encode(:v6, 12)
340199290171201906221318119490500689920

iex> BitwiseIp.Mask.encode(:v4, 128)
** (FunctionClauseError) no function clause matching in BitwiseIp.Mask.encode/2

iex> BitwiseIp.Mask.encode(:v6, -12)
** (FunctionClauseError) no function clause matching in BitwiseIp.Mask.encode/2