Expand description
§gelx_core
Core utilities and logic for
gelxcode generation, powering both thegelxprocedural macro and thegelx_cli.
§Overview
The gelx_core crate is the engine behind the gelx ecosystem. It provides the foundational components and functionalities required for:
- Parsing Gel query files (
.edgeql). - Connecting to a Gel instance to introspect schemas and query types.
- Translating Gel query descriptions into Rust
TokenStreams. - Handling
gelxconfiguration fromCargo.toml([package.metadata.gelx]). - Defining common types, error handling, and utility functions used by both
gelx(the macro crate) andgelx_cli(the command-line tool).
This crate is not typically used directly by end-users but serves as an internal library for the other gelx tools. If you are looking to generate Rust code from Gel queries, you should use either the gelx macro for inline queries or the gelx_cli for file-based generation.
§Functionality
Key functionalities provided by gelx_core include:
- Descriptor Fetching:
get_descriptor_syncandget_descriptorfunctions to fetch query data descriptions from a running Gel instance. - Token Stream Generation:
generate_query_token_streamwhich takes a query description and generates the corresponding Rust code (structs for input/output, and query functions). - Metadata Handling: Structures and functions to parse and manage
GelxMetadatafromCargo.toml. - Type Mapping: Logic to map Gel types to appropriate Rust types (e.g.,
String,Uuid,DateTime, custom enums, and object shapes). - Configuration: Utilities for resolving Gel connection parameters.
- Error Handling: Common error types for the
gelxecosystem.
§Features
gelx_core exposes several features that can be toggled by dependent crates (like gelx and gelx_macros):
with_bigint: Enables support forBigInt.with_bigdecimal: Enables support forBigDecimal.with_chrono: Enables support forchronodate/time types.with_all: A convenience feature that enables allwith_*features.query: Enables generation of query execution functions (depends ongel-tokio).serde: Enables#[derive(Serialize, Deserialize)]for generated structs.builder: Enables#[derive(TypedBuilder)]for generated input structs.strum: Enables#[derive(EnumString, Display)]for generated enums.
These features are typically controlled via the gelx crate’s own features.
§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.
Structs§
- Array
Type - Backlink
- Backlink
Stubs Array - Backlinks
Set - Base
Type - Bases
Set - Enum
Type - Exclusives
Set - Gelx
Features - Gelx
Metadata - The metadata for the
gelxcrate. This can either be specified in theCargo.tomlfile or via CLI arguments. - Globals
Output - Globals
Target - IdRef
- Intersection
OfSet - Module
Name - The name of a resource in the
geldatabase. - Module
Node - Module
Output - Module
Outputs - Module
Tree - Multi
Range Type - Object
Type - Pointer
- Pointer
Flags - Pointers
Set - Pointers
SetPointers Set - Range
Type - Scalar
Type - Tuple
Element Def - Tuple
Elements Set - Tuple
Type - Types
Output - Union
OfSet
Enums§
- Exclusives
- Feature
Name - The name of a feature.
- Gelx
Core Error - The error type for the
gelx_corecrate. - Gelx
Feature Options - Pointer
Kind - Schema
Cardinality - Struct
Element - Type
- Type
Kind
Constants§
- GLOBALS_
QUERY - PROPS_
NAME - QUERY_
PROP_ NAME - Name of the query function.
- TRANSACTION_
PROP_ NAME - TYPES_
QUERY - Query to get all types in the database.
Traits§
Functions§
- generate_
module_ outputs - Generate the custom types.
- generate_
query_ token_ stream - get_
descriptor - Get the query descriptor asynchronously.
- get_
descriptor_ sync - Get the descriptor synchronously.
- get_
package_ root - prettify
- Will format the given source code using
prettyplease. - query_
globals - Execute the desired query.
- resolve_
path - Taken from https://github.com/launchbadge/sqlx/blob/f69f370f25f099fd5732a5383ceffc76f724c482/sqlx-macros-core/src/common.rs#L1C1-L37C2