# `Minga.Parser.BufferRegistry`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/parser/buffer_registry.ex#L1)

Pure identity and lifecycle registry owned by `Minga.Parser.Manager`.

# `meta`

```elixir
@type meta() :: Minga.Parser.BufferRegistration.t()
```

# `register_status`

```elixir
@type register_status() :: :new | :existing | {:replaced, pos_integer()}
```

# `t`

```elixir
@type t() :: %Minga.Parser.BufferRegistry{
  entries: %{required(pid()) =&gt; meta()},
  ids: %{required(pid()) =&gt; pos_integer()},
  last_active_at: %{required(pid()) =&gt; integer()},
  monitors: %{required(pid()) =&gt; reference()},
  next_id: pos_integer(),
  parse_version: non_neg_integer(),
  pids: %{required(pos_integer()) =&gt; pid()}
}
```

# `buffer_id`

```elixir
@spec buffer_id(t(), pid()) :: pos_integer() | nil
```

Returns the parser ID for a buffer PID.

# `count`

```elixir
@spec count(t()) :: non_neg_integer()
```

Returns the number of registrations.

# `entries`

```elixir
@spec entries(t()) :: %{required(pid()) =&gt; meta()}
```

Returns all registrations.

# `evict_inactive`

```elixir
@spec evict_inactive(t(), [pid()], non_neg_integer(), integer()) ::
  {[{pid(), pos_integer(), reference() | nil}], t()}
```

Evicts stale unprotected buffers and returns their identities.

# `fetch`

```elixir
@spec fetch(t(), pid()) :: {:ok, meta()} | :error
```

Returns a registration by PID.

# `monitored?`

```elixir
@spec monitored?(t(), pid(), reference()) :: boolean()
```

Returns whether a DOWN message belongs to the current monitor.

# `new`

```elixir
@spec new() :: t()
```

Creates an empty editor-buffer registry.

# `next_parse_version`

```elixir
@spec next_parse_version(t()) :: {pos_integer(), t()}
```

Allocates the next manager-owned parser version.

# `put`

```elixir
@spec put(t(), pid(), meta()) :: t()
```

Replaces an existing registration; unknown PIDs are ignored.

# `put_monitor`

```elixir
@spec put_monitor(t(), pid(), reference()) :: t()
```

Records the process monitor owned by the parser manager.

# `register`

```elixir
@spec register(t(), pid(), Minga.Parser.BufferConfig.t(), integer()) ::
  {pos_integer(), register_status(), t()}
```

Registers a buffer, preserving identity only while its inert configuration is unchanged.

# `registered_id?`

```elixir
@spec registered_id?(t(), non_neg_integer()) :: boolean()
```

Returns whether a parser ID belongs to an editor buffer.

# `resolve`

```elixir
@spec resolve(t(), non_neg_integer()) :: pid() | nil
```

Returns the buffer PID for a parser ID.

# `restart_all`

```elixir
@spec restart_all(t()) :: t()
```

Resets parser versions and marks every registration for full resync.

# `touch`

```elixir
@spec touch(t(), pid(), integer()) :: t()
```

Refreshes activity for a registered buffer.

# `unregister`

```elixir
@spec unregister(t(), pid()) :: {pos_integer() | nil, reference() | nil, t()}
```

Unregisters a buffer and returns its former parser ID and monitor.

---

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