cratestack-pg
The server-side facade for CrateStack: Postgres (via sqlx), Axum HTTP
bindings, the generated Rust client runtime, and the shared schema /
parser / policy / SQL surface.
When to use this crate
Pick cratestack-pg for backend services: HTTP servers, background
workers, anything that needs the sqlx Postgres runtime, generated Axum
routes, or the in-process generated Rust client.
For embedded / mobile / wasm targets (rusqlite, SQLite, wasm32), depend
on cratestack-sqlite instead. The two crates
are strictly disjoint by design — cratestack-pg does not pull in
libsqlite3-sys, which lets you depend on the official sqlx umbrella
crate alongside it without tripping Cargo's links = "sqlite3"
collision rule.
Installation
Schema macros emit ::cratestack::* paths. Alias this crate as
cratestack via Cargo's package = field:
[]
= { = "cratestack-pg", = "0.6.7" }
Then in code:
include_server_schema!;
SQL views
This facade re-exports ViewDelegate and ViewDelegateNoUnique — the
read-only delegates handed out by runtime.views().<view_snake>()
for every view block in the schema. ViewDelegate exposes
find_many + find_unique and, on @@materialized views, a
refresh() method that runs REFRESH MATERIALIZED VIEW CONCURRENTLY.
ViewDelegateNoUnique (for @@no_unique views) exposes only
find_many — find_unique and refresh() are absent at the type
level. See the Views reference
and ADR-0003.
Features
postgres(default) — gatesdep:cratestack-sqlx(and forwardscratestack-macros/postgres). On by default so every existingdb = Postgresconsumer sees zero behavior change. A consumer that only ever usesdb = Noneschemas can disable it withdefault-features = false(re-adding whichever ofdecimal-rust-decimal/codec-jsonit still wants) to keepsqlxand its transitive dependency tree out of the build entirely — or depend oncratestack-apiinstead, which never pulls incratestack-sqlxat all.decimal-rust-decimal(default) —Decimalcolumns userust_decimal.decimal-bigdecimal— alternativebigdecimalbackend.codec-json(default) — forwards the JSON codec to the generated client runtime, soinclude_client_schema!offers both CBOR and JSON.grpc— realtransport grpcRust codegen (server tonic service + Rust gRPC client). Off by default: pulls intonic/prostfor every consumer otherwise, whether or not they use gRPC. Without it, aGrpcschema failsinclude_server_schema!/include_client_schema!with acompile_error!pointing here.crypto-aws-lc-rs— not implemented yet, enabling it is a hardcompile_error!. Reserved for a future FIPS-validatedaws-lc-rsrustls provider; seeinstall_fips_crypto_provider()'s doc comment and #334.