RustQ.Binding.Index (rustq v0.9.1)

Copy Markdown View Source

Lookup table for normalized RustQ callable metadata.

The index stores RustQ.Binding.Callable values under local and target-qualified call keys. Method callables are indexed both by their full Rust signature arity and, when they include a receiver/self argument, by the Elixir-style call arity that excludes the receiver. This lets lowering ask for Canvas.draw_rect(rect) even when the Rust signature is draw_rect(&self, rect: Rect).

Summary

Functions

Returns expected argument types for a callable lookup.

Fetches a callable by optional target, function name, and call arity.

Returns a callable by optional target, function name, and call arity or nil.

Returns method receiver targets for a method name and Elixir-style call arity.

Builds a callable lookup index.

Adds a callable to the index under all lookup keys it supports.

Returns the return type for a callable lookup or nil when unknown/unit.

Types

key()

@type key() :: {String.t() | nil, String.t(), non_neg_integer()}

t()

@type t() :: %RustQ.Binding.Index{
  by_key: %{optional(key()) => RustQ.Binding.Callable.t()}
}

Functions

argument_types(index, target, name, arity)

@spec argument_types(
  t(),
  String.t() | atom() | nil,
  String.t() | atom(),
  non_neg_integer()
) ::
  [RustQ.Meta.Type.t()] | nil

Returns expected argument types for a callable lookup.

fetch(index, target, name, arity)

@spec fetch(t(), String.t() | atom() | nil, String.t() | atom(), non_neg_integer()) ::
  {:ok, RustQ.Binding.Callable.t()} | :error

Fetches a callable by optional target, function name, and call arity.

get(index, target, name, arity)

@spec get(t(), String.t() | atom() | nil, String.t() | atom(), non_neg_integer()) ::
  RustQ.Binding.Callable.t() | nil

Returns a callable by optional target, function name, and call arity or nil.

method_targets(index, name, arity)

@spec method_targets(t(), String.t() | atom(), non_neg_integer()) :: [String.t()]

Returns method receiver targets for a method name and Elixir-style call arity.

new(index)

@spec new([RustQ.Binding.Callable.t()] | t() | nil) :: t()

Builds a callable lookup index.

put(index, callable)

@spec put(t(), RustQ.Binding.Callable.t()) :: t()

Adds a callable to the index under all lookup keys it supports.

return_type(index, target, name, arity)

@spec return_type(
  t(),
  String.t() | atom() | nil,
  String.t() | atom(),
  non_neg_integer()
) ::
  RustQ.Meta.Type.t() | nil

Returns the return type for a callable lookup or nil when unknown/unit.