# `Slap.SlateDB.Iterator`
[🔗](https://github.com/mjrusso/slap/blob/slap_slatedb-v0.2.0/slap_slatedb/lib/slap/slatedb/iterator.ex#L1)

A low-level iterator over a key range.

Most code should use the streams from `Slap.SlateDB.scan/2`,
`Slap.SlateDB.Snapshot.scan/2` and `Slap.SlateDB.Transaction.scan/2` instead. Use
this module when you need `seek/2`.

An iterator is not safe to share between processes that read from it at the
same time. Calls are serialized, so the rows each process sees will
interleave.

# `t`

```elixir
@opaque t()
```

# `next_batch`

```elixir
@spec next_batch(t(), pos_integer(), keyword()) ::
  {:ok, [{binary(), binary()} | {binary(), binary(), non_neg_integer() | nil}]}
  | {:error, Slap.SlateDB.Error.t()}
```

Returns up to `max` rows as `{key, value}` tuples. An iterator opened with
`with_versions: true` returns `{key, value, version}` tuples. The version
is nil for a transaction's uncommitted writes. Returns `{:ok, []}` when
the iterator is done. `:timeout` applies to this batch fetch.

# `seek`

```elixir
@spec seek(t(), binary(), keyword()) :: :ok | {:error, Slap.SlateDB.Error.t()}
```

Moves the iterator forward to the first key that is at least `key`.

The key must be inside the iterator's range and not before its current
position. An iterator with `order: :desc` cannot seek; it returns an
`:invalid` error.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
