RustQ.Meta.AST (rustq v1.0.0-rc.19)

Copy Markdown View Source

Builds RustQ AST items from defrust metadata and explicit quoted bodies.

Summary

Functions

Lowers one defrust definition, with its specs, type aliases, Rust module aliases, and the callables and macros it may use, to its RustQ AST item.

Builds the Rust struct, enum, and alias items the module's declared types need.

Callable metadata for the module's own functions, from their specs.

Returns one generated Rust enum type item by name, raising on absence or kind mismatch.

Expands ordinary Elixir macros in a body in env before it is lowered.

Returns one generated defrust function AST by name, raising when absent.

Returns all generated defrust function AST nodes from a compiled module.

Returns selected generated defrust function AST nodes.

Returns every generated Rust type item from a compiled RustQ module.

Groups built items into their Rust modules and impl blocks, in definition order.

Groups built items as group_items/2 does, without Rust module aliases.

Returns one generated Rust implementation block for a target.

Returns every generated Rust implementation block from a compiled module.

Returns every generated Rust item from a compiled RustQ module.

Builds a structural invocation of a generated Rust item macro.

Returns one generated defrustmacro item AST by name, raising when absent.

Returns selected generated defrustmacro item AST nodes.

Lowers one Rusty-Elixir body to a Rust function from explicit :args, :returns, and :do, without a module's specs; used to build functions from generators.

Returns one generated Rust struct type item by name, raising on absence or kind mismatch.

Builds Rust struct items for selected map-backed @type declarations.

Returns one generated Rust type item by name, raising when absent.

Functions

build_ast(definition, specs, type_aliases, rust_modules, env, external_callables \\ [], external_static_types \\ %{}, rust_macros \\ %{})

Lowers one defrust definition, with its specs, type aliases, Rust module aliases, and the callables and macros it may use, to its RustQ AST item.

build_type_asts(type_aliases)

Builds the Rust struct, enum, and alias items the module's declared types need.

callables_from_specs(specs, type_aliases)

@spec callables_from_specs([term()], map()) :: [RustQ.Binding.Callable.t()]

Callable metadata for the module's own functions, from their specs.

enum_type_item!(module, name)

@spec enum_type_item!(module(), atom() | String.t()) :: RustQ.Rust.AST.Enum.t()

Returns one generated Rust enum type item by name, raising on absence or kind mismatch.

expand_body_macros(body_ast, env)

Expands ordinary Elixir macros in a body in env before it is lowered.

function!(module, name, opts \\ [])

@spec function!(module(), atom() | String.t(), keyword()) ::
  RustQ.Rust.AST.Function.t()

Returns one generated defrust function AST by name, raising when absent.

functions(module)

@spec functions(module()) :: [RustQ.Rust.AST.Function.t()]

Returns all generated defrust function AST nodes from a compiled module.

Raises ArgumentError when the module does not contain compiled defrust metadata.

functions!(module, names)

@spec functions!(module(), [atom() | String.t()]) :: [RustQ.Rust.AST.Function.t()]

Returns selected generated defrust function AST nodes.

generated_type_items(module)

@spec generated_type_items(module()) :: [RustQ.Rust.AST.item()]

Returns every generated Rust type item from a compiled RustQ module.

group_items(built_asts, rust_modules \\ %{})

Groups built items into their Rust modules and impl blocks, in definition order.

group_module_asts(built_asts)

Groups built items as group_items/2 does, without Rust module aliases.

impl!(module, target, opts \\ [])

@spec impl!(module(), atom() | String.t() | [atom() | String.t()], keyword()) ::
  RustQ.Rust.AST.Impl.t()

Returns one generated Rust implementation block for a target.

Pass trait: Name to select a trait implementation. Without :trait, only inherent implementations match. Raises when no implementation matches or when the selector is ambiguous.

impls(module)

@spec impls(module()) :: [RustQ.Rust.AST.Impl.t()]

Returns every generated Rust implementation block from a compiled module.

items(module)

@spec items(module()) :: [RustQ.Rust.AST.item()]

Returns every generated Rust item from a compiled RustQ module.

This is the public structural accessor for generated type declarations, functions, modules, and implementation blocks.

macro_call!(module, name, args)

@spec macro_call!(module(), atom() | String.t(), keyword()) ::
  RustQ.Rust.AST.MacroItemCall.t()

Builds a structural invocation of a generated Rust item macro.

args gives each capture its value: an atom or string for an :ident, a value for a :literal, and RustQ AST or source for an :expr or :ty.

macro_item!(module, name)

@spec macro_item!(module(), atom() | String.t()) :: RustQ.Rust.AST.MacroItem.t()

Returns one generated defrustmacro item AST by name, raising when absent.

macro_items!(module, names)

@spec macro_items!(module(), [atom() | String.t()]) :: [RustQ.Rust.AST.MacroItem.t()]

Returns selected generated defrustmacro item AST nodes.

quoted(name, opts)

@spec quoted(
  atom(),
  keyword()
) :: RustQ.Rust.AST.Function.t()

Lowers one Rusty-Elixir body to a Rust function from explicit :args, :returns, and :do, without a module's specs; used to build functions from generators.

struct_type_item!(module, name)

@spec struct_type_item!(module(), atom() | String.t()) :: RustQ.Rust.AST.Struct.t()

Returns one generated Rust struct type item by name, raising on absence or kind mismatch.

struct_type_items(module, names, opts \\ [])

@spec struct_type_items(module(), [atom()], keyword()) :: [RustQ.Rust.AST.Struct.t()]

Builds Rust struct items for selected map-backed @type declarations.

Use :derive, :attrs, and :vis to adapt the structural type item at a boundary such as Rustler encoding without duplicating its fields.

type_item!(module, name)

@spec type_item!(module(), atom() | String.t()) :: RustQ.Rust.AST.item()

Returns one generated Rust type item by name, raising when absent.