Iptrie.find-exclamation-mark

You're seeing just the function find-exclamation-mark, go back to Iptrie module for more information.

Specs

find!(t(), prefix()) :: {prefix(), any()} | KeyError | ArgumentError

Finds a prefix,value-pair for given prefix from trie using a longest prefix match.

Convenience wrapper for Iptrie.fetch!/3 with match: :lpm.

Examples

iex> ipt = new()
...> |> put("10.10.10.0/24", "ten")
...> |> put("11.11.11.0/24", "eleven")
iex>
iex> find!(ipt, "10.10.10.0/24")
{"10.10.10.0/24", "ten"}
iex>
iex> find!(ipt, "10.10.10.10")
{"10.10.10.0/24", "ten"}
iex>
iex> find!(ipt, "12.12.12.12")
** (KeyError) prefix "12.12.12.12" not found

iex> ipt = new()
iex> find!(ipt, "13.13.13.333")
** (ArgumentError) expected a valid prefix, got "13.13.13.333"