Pfx.contrast

You're seeing just the function contrast, go back to Pfx module for more information.

Specs

contrast(prefix(), prefix()) ::
  :equal | :more | :less | :left | :right | :disjoint

Contrasts pfx1 to pfx2.

Contrasting two prefixes yields one of:

  • :equal pfx1 is equal to pfx2
  • :more pfx1 is a more specific version of pfx2
  • :less pfx1 is a less specific version of pfx2
  • :left pfx1 is left-adjacent to pfx2
  • :right pfx1 is right-adjacent to pfx2
  • :disjoint pfx1 has no match with pfx2 whatsoever.

Examples

iex> contrast("10.10.0.0/16", "10.10.0.0/16")
:equal

iex> contrast("10.10.10.0/24", "10.10.0.0/16")
:more

iex> contrast("10.0.0.0/8", "10.255.255.0/24")
:less

iex> contrast("1.2.3.0/24", "1.2.4.0/24")
:left

iex> contrast("1.2.3.4/30", "1.2.3.0/30")
:right

iex> contrast("10.10.0.0/16", "9.0.0.0/8")
:disjoint

iex> contrast("10.10.0.0/16", %Pfx{bits: <<10,12>>, maxlen: 32})
:disjoint