Iptrie.fetch
You're seeing just the function
fetch
, go back to Iptrie module for more information.
Specs
Fetches the prefix,value-pair for given prefix
from trie
.
Returns one of:
{:ok, {prefix, value}}
in case of success{:error, :notfound}
ifprefix
is not present intrie
{:error, :einval}
in case of an invalidprefix
, and{:error, :bad_trie}
in casetrie
is not anIptrie.t/0
Optionally fetches based on a longest prefix match by specifying match: :lpm
.
Example
iex> ipt = new()
...> |> put("1.1.1.0/24", "one")
...> |> put("2.2.2.0/24", "two")
iex>
iex> fetch(ipt, "1.1.1.0/24")
{:ok, {"1.1.1.0/24", "one"}}
iex>
iex> fetch(ipt, "1.1.1.1")
{:error, :notfound}
iex>
iex> fetch(ipt, "1.1.1.1", match: :lpm)
{:ok, {"1.1.1.0/24", "one"}}
iex>
iex> fetch(ipt, "13.13.13.333")
{:error, :einval}