gelx_macros
Procedural macros for the
gelxcrate, enabling compile-time generation of typed Rust code from Gel queries.
Overview
The gelx_macros crate provides the gelx_raw! procedural macro, which is the primary way users interact with gelx for inline query code generation.
When you use gelx_raw!(module_name, query: "select ...") or gelx_raw!(module_name, file: "path/to/query.edgeql") in your Rust code, this crate is responsible for:
- Parsing the macro input (module name and query string or file path).
- Invoking
gelx_coreto fetch query descriptions from a Gel instance. - Utilizing
gelx_coreto generate the RustTokenStreamfor the query module, including input/output structs and query functions. - Returning the generated
TokenStreamto the Rust compiler to be included in your crate.
This crate is an internal dependency of the main gelx crate and is not intended to be used directly by end-users, other than through the gelx! macro re-exported by the gelx crate.
Macro Usage
The main macro provided is gelx!. It can be used in two ways:
-
Inline Query:
use gelx; // Assuming gelx re-exports the macro gelx!; // This generates a `my_query_module` with Input/Output structs and query // functions. -
File-based Query:
use gelx; // Assuming a file `queries/get_user.edgeql` exists relative to your Cargo.toml gelx!; // Or, if the filename matches the module name (e.g., // `queries/my_module.edgeql`): gelx!;
For detailed usage examples and configuration, please refer to the documentation of the main gelx crate.
Features
gelx_macros forwards its features to gelx_core. The available features are:
with_bigintwith_bigdecimalwith_chronowith_allqueryserdebuilderstrum
These features are typically controlled via the gelx crate's own features when you add gelx as a dependency.
Contributing
This crate is part of the gelx workspace. Please refer to the main project's contributing guide for details on how to set up the development environment and contribute.
License
Unlicense, see the license file in the root of the workspace.