# `Concord.KV.Selector`
[🔗](https://github.com/gsmlg-dev/concord/blob/main/lib/concord/kv/selector.ex#L1)

Unified selector type for addressing keys in Concord.

Selectors are used across the KV, Transaction, and Sync APIs to specify
which keys an operation targets. Three forms are supported:

- `{:key, binary()}` — Exactly one key
- `{:prefix, binary()}` — All keys starting with the given prefix
- `{:range, start :: binary(), end_exclusive :: binary()}` — All keys
  in the half-open interval `[start, end)`

`{:prefix, p}` is sugar for `{:range, p, p <> <<0xFF, 0xFF, ...>>}`.

# `t`

```elixir
@type t() ::
  {:key, binary()}
  | {:prefix, binary()}
  | {:range, start :: binary(), end_exclusive :: binary()}
```

# `matches?`

```elixir
@spec matches?(t(), binary()) :: boolean()
```

Checks if a key matches the given selector.

# `prefix_end`

```elixir
@spec prefix_end(binary()) :: binary()
```

Returns the upper bound binary for a prefix scan.

For a prefix `p`, the upper bound is `p` with each trailing byte incremented,
effectively matching all keys that start with `p`.

# `validate`

```elixir
@spec validate(term()) :: :ok | {:error, atom()}
```

Validates a selector value.

Returns `:ok` if valid, `{:error, reason}` otherwise.

