# `RustQ.Meta.Type`
[🔗](https://github.com/dannote/rustq/blob/v0.11.1/lib/rustq/meta/type.ex#L1)

Structural metadata for an Elixir typespec lowered by RustQ.

`RustQ.Spec.type/2` and `RustQ.Spec.aliases/1` return this struct. The
`:kind` field is the primary semantic classification (`:f64`, `:bool`,
`:tuple`, `:struct`, `:enum`, `:type`, and so on). The `:ast` field carries
the RustQ Rust type AST used for rendering, `:rust` is its rendered Rust type,
and `:meta` carries shape-specific metadata such as:

  * `:elements` for tuple element types
  * `:fields` for map/struct field types
  * `:elixir_name` for local aliases and enum aliases
  * `:elixir_module`, `:elixir_type`, and `:elixir_args` for external
    Elixir remote types such as `Skia.Path.t()`

Prefer consuming this structure directly at codegen boundaries instead of
parsing rendered Rust type strings.

# `category`

```elixir
@type category() ::
  :number
  | :integer
  | :boolean
  | :atom
  | :string
  | :term
  | :enum
  | {:tuple, [t()]}
  | {:alias, atom()}
  | :type
```

# `t`

```elixir
@type t() :: %RustQ.Meta.Type{
  ast: term(),
  kind: atom(),
  meta: map(),
  rust: String.t()
}
```

# `callable_target`

```elixir
@spec callable_target(t()) :: String.t() | nil
```

Returns a callable lookup target normalized from structural type metadata.

# `category`

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

Returns the semantic category for a lowered RustQ type.

# `compatible?`

```elixir
@spec compatible?(t() | nil, t() | nil) :: boolean()
```

Returns true when two lowered types are semantically compatible.

# `compatible_with_expected?`

```elixir
@spec compatible_with_expected?(t() | nil, t() | nil) :: boolean()
```

Returns true when a value type can satisfy a callable expected argument type.

# `expected_input`

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

Returns the natural Rusty-Elixir input type for a callable expected type.

This normalizes Rust adapter types into the value shape an author should pass
before call-site coercions are emitted. For example, `&T` expects an authored
`T`, `&[T]` expects an authored `Vec<T>`, and `impl IntoIterator<Item = T>`
expects an authored `Vec<T>`.

# `expected_value`

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

Returns the concrete value type expected by a callable argument.

This peels structural argument adapters such as `impl Into<T>` and the common
`impl Into<Option<(A, B)>>` tuple case so propagation inference can compare a
decoder's success type with the value the Rust call actually expects.

# `external?`

```elixir
@spec external?(t(), module(), atom()) :: boolean()
```

Returns true when a type originated from a specific Elixir remote type.

# `field_type`

```elixir
@spec field_type(t(), atom()) :: t() | nil
```

Returns a named structural field type, when available.

# `from_syn`

```elixir
@spec from_syn(RustQ.Syn.type()) :: t()
```

Converts structured `RustQ.Syn.Type` metadata into a RustQ meta type.

This is the first bridge from upstream Rust signatures into Rusty-Elixir type
metadata. It preserves structured wrappers such as refs, options, results,
slices, and paths, while falling back to `TypeRaw` for Syn shapes that do not
yet expose enough structure to rebuild a richer RustQ AST node.

# `inner`

```elixir
@spec inner(t()) :: t() | nil
```

Returns the success/inner type of `Result`, `NifResult`, or `Option` wrappers.

# `lifetime?`

```elixir
@spec lifetime?(t(), atom()) :: boolean()
```

Returns true when the type AST structurally contains the given lifetime.

# `option`

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

Constructs option type metadata for an inner type.

# `parse`

```elixir
@spec parse(Macro.t(), map()) :: t()
```

# `propagates?`

```elixir
@spec propagates?(t()) :: boolean()
```

Returns true for wrapper types that can propagate with Rust `?`.

# `ref`

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

Constructs reference type metadata for an inner type.

# `ref_inner`

```elixir
@spec ref_inner(t()) :: t() | nil
```

Returns the referenced inner type for `&T` or `&mut T` metadata.

# `slice_inner`

```elixir
@spec slice_inner(t()) :: t() | nil
```

Returns the element type for `[T]` / `&[T]` metadata.

# `vec`

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

Constructs `Vec<T>` type metadata.

# `vec_inner`

```elixir
@spec vec_inner(t()) :: t() | nil
```

Returns the element type for `Vec<T>` metadata.

---

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