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.
| Crate | Responsibility | Key Modules |
|---|---|---|
| ryx-core | Base types & Traits | types.rs (Connection/Transaction Enums) |
| ryx-backend | DB Adapters & Decoding | backends/, utils.rs (RowView logic) |
| ryx-query | SQL Compiler | ast.rs, compiler.rs, lookup.rs |
| ryx-python | PyO3 Bindings | lib.rs (Module entry, Type bridge) |
ryx-python โ Module Entryโ
Exposes to Python:
PyQueryBuilderโ Python-facing query buildersetup_pool()โ Initialize the connection poolpool_stats()โ Get pool statisticsbegin_tx(),commit_tx(),rollback_tx()โ Transaction operationssavepoint(),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 |
| Crate | Version | Role |
|---|---|---|
pyo3 | >=0.27.2, <0.29 | Python โ Rust bindings |
pyo3-async-runtimes | 0.28 | Rust futures โ Python awaitables |
sqlx | 0.8.6 | Async SQL driver |
tokio | 1.40 | Async runtime |
thiserror | 2 | Error derivation |
serde_json | โ | JSON value handling |
tracing | โ | Structured logging |
Next Stepsโ
โ Query Compiler โ How AST becomes SQL