Skip to main content

Rust Core

The compiled engine that powers Ryx. Built with PyO3, sqlx, and tokio.

Module Overviewโ€‹

Ryx is organized as a Rust workspace to isolate concerns and optimize build times.

CrateResponsibilityKey Modules
ryx-coreBase types & Traitstypes.rs (Connection/Transaction Enums)
ryx-backendDB Adapters & Decodingbackends/, utils.rs (RowView logic)
ryx-querySQL Compilerast.rs, compiler.rs, lookup.rs
ryx-pythonPyO3 Bindingslib.rs (Module entry, Type bridge)

ryx-python โ€” Module Entryโ€‹

Exposes to Python:

  • PyQueryBuilder โ€” Python-facing query builder
  • setup_pool() โ€” Initialize the connection pool
  • pool_stats() โ€” Get pool statistics
  • begin_tx(), commit_tx(), rollback_tx() โ€” Transaction operations
  • savepoint(), rollback_to(), release_savepoint() โ€” Savepoint operations
  • Type conversion: py_to_sql_value(), json_to_py()

ryx-core โ€” Base Typesโ€‹

Defines the foundational enums that enable Enum Dispatch:

pub enum RyxConnection {
Postgres(PgPool),
MySql(MySqlPool),
Sqlite(SqlitePool),
}

This approach eliminates vtable overhead and allows the compiler to inline database-specific calls.

ryx-backend โ€” Execution & Decodingโ€‹

Handles the actual communication with the database and the high-performance row decoding system.

// Optimized for zero-allocation
pub async fn fetch_all(query: CompiledQuery) -> Result<Vec<RowView>>
pub async fn fetch_count(query: CompiledQuery) -> Result<i64>
pub async fn fetch_one(query: CompiledQuery) -> Result<RowView>
pub async fn execute(query: CompiledQuery) -> Result<MutationResult>

ryx-query โ€” The Compilerโ€‹

Transforms the QueryNode AST into optimized SQL strings and bound values.

Dependenciesโ€‹

| Crate | Version | Role |

CrateVersionRole
pyo3>=0.27.2, <0.29Python โ†” Rust bindings
pyo3-async-runtimes0.28Rust futures โ†’ Python awaitables
sqlx0.8.6Async SQL driver
tokio1.40Async runtime
thiserror2Error derivation
serde_jsonโ€”JSON value handling
tracingโ€”Structured logging

Next Stepsโ€‹

โ†’ Query Compiler โ€” How AST becomes SQL