cratestack-macros 0.7.1

Rust-native schema-first framework for typed HTTP APIs, generated clients, and backend services.
Documentation
//! Runtime types emitted inside `pub mod cratestack_schema { ... }`:
//! `Cratestack` (the delegate hub), `BoundCratestack` (context-bound
//! view), `CratestackBuilder`, plus `schema_summary()`.
//!
//! Dispatches on `db` (cratestack#328): `db = Postgres` ([`postgres`])
//! keeps the pre-existing sqlx-backed shape byte-for-byte; `db = None`
//! ([`none`]) emits a genuinely different, database-free `Cratestack`
//! rather than threading an always-`None` `Option<PgPool>` through the
//! same type. See `none`'s module doc for the full rationale.

mod none;
mod postgres;
#[cfg(test)]
mod tests;

use super::super::parse::ServerDb;

pub(super) fn build_runtime_block(
    db: ServerDb,
    model_accessors: &[proc_macro2::TokenStream],
    bound_model_accessors: &[proc_macro2::TokenStream],
    view_accessors: &[proc_macro2::TokenStream],
) -> proc_macro2::TokenStream {
    match db {
        ServerDb::Postgres => {
            postgres::build_runtime_block(model_accessors, bound_model_accessors, view_accessors)
        }
        // Zero models are guaranteed under `db = None` (cratestack#327's
        // datasource guard), so `model_accessors`/`bound_model_accessors`/
        // `view_accessors` are always empty here — the `none` variant
        // doesn't take them at all rather than accepting and discarding
        // dead parameters.
        ServerDb::None => none::build_runtime_block(),
    }
}