Iptrie.lookup

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

Specs

lookup(t(), prefix()) :: {prefix(), any()} | nil

Returns the prefix,value-pair, whose prefix is the longest match for given search prefix.

Returns nil if there is no match for search prefix.

Examples

iex> ipt = new()
...> |> put("1.1.1.0/24", 1)
...> |> put("2.2.2.0/24", 2)
...> |> put("acdc:1975::/32", 3)
...> |> put("acdc:2021::/32", 4)
iex>
iex> lookup(ipt, "1.1.1.1")
{"1.1.1.0/24", 1}
iex> lookup(ipt, "acdc:1975:1::")
{"acdc:1975:0:0:0:0:0:0/32", 3}
iex>
iex> lookup(ipt, "3.3.3.3")
nil
iex> lookup(ipt, "3.3.3.300")
** (ArgumentError) expected a ipv4/ipv6 CIDR or EUI-48/64 string, got "3.3.3.300"