Expand description
AuDB Runtime Library
Minimal runtime support for code generated by audb-codegen.
This crate provides the essential types and traits needed by generated code to execute queries against a database. The runtime is intentionally minimal, with most work (parsing, validation, optimization) happening at compile time.
§Core Components
Database- Connection wrapper with async query execution methodsQueryError- Comprehensive error types for runtime failuresQueryResult,Row,Value- Type system for query resultsQueryExecutor- Trait for type-safe async query executionFromRow- Trait for deserializing rows into Rust types
§Design Philosophy
The runtime follows a compile-time-first approach:
- Queries are parsed and validated at build time
- Type checking happens during compilation
- Optimization is done by the code generator
- Runtime only handles execution and result deserialization
This results in:
- Zero runtime parsing overhead
- Compile-time type safety
- Minimal binary size contribution (~1MB)
- Excellent performance (no query interpretation)
§Example Usage
use audb_runtime::{Database, QueryError};
async fn example() -> Result<(), QueryError> {
// Open database connection
let db = Database::open("./data").await?;
// Execute queries (typically via generated code)
let result = db.execute_hyperql("SELECT * FROM users").await?;
// Clean shutdown
db.close().await?;
Ok(())
}§Integration with Generated Code
The runtime is designed to work seamlessly with code generated by audb-codegen.
Generated query functions use the Database methods and FromRow trait to
provide type-safe, compile-time-checked query execution.
§Module Organization
database- Database connection and query executionerror- Error types and utilitiestypes- Result types (QueryResult, Row, Value)executor- Traits for type-safe execution and deserialization
Structs§
- Database
- Database connection wrapper
- Query
Result - Result of a query execution
- Row
- A single row from a query result
Enums§
- Query
Error - Errors that can occur during query execution
- Value
- A value that can be stored in a database
Traits§
- FromRow
- Trait for deserializing a row into a Rust type
- From
Value - Helper trait for converting Values to specific types
- Query
Executor - Trait for executing queries with type-safe results
Type Aliases§
- Result
- Alias for Result with QueryError