audb-runtime 0.1.10

Runtime library for AuDB database applications with Manifold backend
Documentation

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 methods
  • QueryError - Comprehensive error types for runtime failures
  • QueryResult, Row, Value - Type system for query results
  • QueryExecutor - Trait for type-safe async query execution
  • FromRow - 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 execution
  • error - Error types and utilities
  • types - Result types (QueryResult, Row, Value)
  • executor - Traits for type-safe execution and deserialization