NetAddr.mask_to_length_2

You're seeing just the function mask_to_length_2, go back to NetAddr module for more information.
Link to this function

mask_to_length_2(address_mask)

View Source

Specs

mask_to_length_2(binary()) :: {:ok, non_neg_integer()} | {:error, :einval}

Convert address_mask to an address length.

Unlike mask_to_length/1, this function returns {:ok, length}, on success, and {:error, :einval}, otherwise. In particular, this function rejects a mask that contains non-consecutive ones bits.

Examples

iex> NetAddr.mask_to_length_2(<<255,255,248,0>>)
{:ok, 21}

iex> NetAddr.mask_to_length_2(<<14,249,150,22>>)
{:error, :einval}