gelx_macros

Crates.iogelx_macros
lib.rsgelx_macros
version0.8.5
created_at2025-05-16 08:54:42.612494+00
updated_at2025-08-02 07:55:47.253259+00
descriptionThe proc-macro crate for the `gelx` crate.
homepagehttps://geldata.com
repositoryhttps://github.com/ifiokjr/gelx
max_upload_size
id1676237
size95,111
Ifiok Jr. (ifiokjr)

documentation

README

gelx_macros


Procedural macros for the gelx crate, enabling compile-time generation of typed Rust code from Gel queries.


Crate Docs Status Unlicense codecov

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_core to fetch query descriptions from a Gel instance.
  • Utilizing gelx_core to generate the Rust TokenStream for the query module, including input/output structs and query functions.
  • Returning the generated TokenStream to 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:

  1. Inline Query:

    use gelx::gelx; // Assuming gelx re-exports the macro
    
    gelx!(my_query_module, "SELECT { message := <str>$arg }");
    
    // This generates a `my_query_module` with Input/Output structs and query
    // functions.
    
  2. File-based Query:

    use gelx::gelx;
    
    // Assuming a file `queries/get_user.edgeql` exists relative to your Cargo.toml
    gelx!(get_user_module, file: "queries/get_user.edgeql");
    
    // Or, if the filename matches the module name (e.g.,
    // `queries/my_module.edgeql`):
    gelx!(my_module);
    

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_bigint
  • with_bigdecimal
  • with_chrono
  • with_all
  • query
  • serde
  • builder
  • strum

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.

Commit count: 161

cargo fmt