# `RustQ.Syn.Index`
[🔗](https://github.com/dannote/rustq/blob/v0.11.1/lib/rustq/syn/index.ex#L1)

In-memory index of Rust source metadata parsed by `RustQ.Syn`.

Use an index when a generator needs to query many Rust files without keeping
project-specific source maps. The index stores parsed files by path and offers
lookup helpers for impl blocks and methods by target type.

It also indexes Rust `use` items and `type` aliases. Generators can inspect
them directly with `uses/1` and `type_aliases/1`, or ask for the public Rust
name that exposes a native/bindings type with `public_type_name/2` and
`public_type_name!/2`. Reexport chains such as `pub use paint::Cap as
PaintCap;` are followed so callers can prefer the crate's public API surface
over internal module names.

# `t`

```elixir
@type t() :: %RustQ.Syn.Index{
  files: %{required(Path.t()) =&gt; RustQ.Syn.File.t()},
  package: RustQ.Cargo.Package.t() | nil
}
```

# `cached_package`

```elixir
@spec cached_package(
  String.t(),
  keyword()
) :: t()
```

Returns a cached index for all Rust sources in a Cargo package.

The first caller builds a structural package index from Cargo metadata and the
package's Rust source files. Concurrent callers for the same package/config are
serialized so parallel compilation does not stampede Cargo metadata or package
cache access; later callers read the already-built index from `:persistent_term`.

Cached entries are fingerprinted from the Cargo manifest/lockfile inputs and
indexed Rust source file mtimes/sizes. If any of those files change, the next
caller rebuilds the package index.

# `clear_cached_package`

```elixir
@spec clear_cached_package(
  String.t(),
  keyword()
) :: :ok
```

Clears a cached package index.

# `enum`

```elixir
@spec enum(t(), String.t()) :: {:ok, RustQ.Syn.Enum.t()} | :error
```

Fetches an enum by name.

# `enum!`

```elixir
@spec enum!(t(), String.t()) :: RustQ.Syn.Enum.t()
```

Fetches an enum by name, raising if missing.

# `enums`

```elixir
@spec enums(t()) :: [RustQ.Syn.Enum.t()]
```

Returns all indexed top-level enums.

# `from_package`

```elixir
@spec from_package(
  String.t(),
  keyword()
) :: t()
```

Builds an index for all Rust sources in a Cargo package.

# `from_paths`

```elixir
@spec from_paths(
  [Path.t()],
  keyword()
) :: t()
```

Builds an index from Rust source file paths.

# `impls`

```elixir
@spec impls(t()) :: [RustQ.Syn.Impl.t()]
```

Returns all indexed top-level impl blocks.

# `impls`

```elixir
@spec impls(t(), String.t()) :: [RustQ.Syn.Impl.t()]
```

Returns impl blocks whose target type matches `target`.

# `method`

```elixir
@spec method(t(), String.t(), String.t()) :: {:ok, RustQ.Syn.Method.t()} | :error
```

Fetches a method from impl blocks matching `target`.

# `method!`

```elixir
@spec method!(t(), String.t(), String.t()) :: RustQ.Syn.Method.t()
```

Fetches a method from impl blocks matching `target`, raising if missing.

# `methods`

```elixir
@spec methods(t(), String.t()) :: [RustQ.Syn.Method.t()]
```

Returns all methods from impl blocks matching `target`.

# `public_type_name`

```elixir
@spec public_type_name(t(), String.t()) :: {:ok, String.t()} | :error
```

Finds the public Rust type name that aliases a target Rust type name.

# `public_type_name!`

```elixir
@spec public_type_name!(t(), String.t()) :: String.t()
```

Finds the public Rust type name that aliases a target Rust type name, raising if missing.

# `static`

```elixir
@spec static(t(), String.t()) :: {:ok, RustQ.Syn.Static.t()} | :error
```

Fetches a top-level static item by name.

# `statics`

```elixir
@spec statics(t()) :: [RustQ.Syn.Static.t()]
```

Returns all indexed top-level static items.

# `type_alias`

```elixir
@spec type_alias(t(), String.t()) :: {:ok, RustQ.Syn.TypeAlias.t()} | :error
```

Fetches a top-level type alias by name.

# `type_alias!`

```elixir
@spec type_alias!(t(), String.t()) :: RustQ.Syn.TypeAlias.t()
```

Fetches a top-level type alias by name, raising if missing.

# `type_aliases`

```elixir
@spec type_aliases(t()) :: [RustQ.Syn.TypeAlias.t()]
```

Returns all indexed top-level type aliases.

# `use_alias`

```elixir
@spec use_alias(t(), String.t()) :: {:ok, RustQ.Syn.Use.t()} | :error
```

Fetches a top-level use alias by alias name.

# `use_alias!`

```elixir
@spec use_alias!(t(), String.t()) :: RustQ.Syn.Use.t()
```

Fetches a top-level use alias by alias name, raising if missing.

# `uses`

```elixir
@spec uses(t()) :: [RustQ.Syn.Use.t()]
```

Returns all indexed top-level use aliases.

---

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