Iptrie.fetch

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

fetch(trie, prefix, opts \\ [])

View Source

Specs

fetch(t(), prefix(), keyword()) :: {:ok, {prefix(), any()}} | {:error, atom()}

Fetches the prefix,value-pair for given prefix from trie.

Returns one of:

  • {:ok, {prefix, value}} in case of success
  • {:error, :notfound} if prefix is not present in trie
  • {:error, :einval} in case of an invalid prefix, and
  • {:error, :bad_trie} in case trie is not an Iptrie.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}