1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
//! CrateStack server facade — Postgres (sqlx) + Axum.
//!
//! This crate is the server-side slice of the framework. It re-exports the
//! shared schema / parser / policy / SQL surface plus the sqlx (Postgres)
//! runtime, Axum HTTP bindings, and the generated Rust client runtime.
//!
//! It deliberately does **not** depend on `cratestack-rusqlite`. That keeps
//! `libsqlite3-sys` out of the dep graph, so consumers can use the official
//! `sqlx` umbrella crate (which optionally declares `sqlx-sqlite` and trips
//! Cargo's `links = "sqlite3"` collision rule) without needing a local
//! `sqlx-shim` workaround.
//!
//! For embedded / mobile / wasm targets, depend on `cratestack-sqlite`
//! instead. The two crates are strictly disjoint by design.
//!
//! Schema macros emit `::cratestack::*` paths, so consumers rename this
//! crate via Cargo's `package =` field:
//!
//! ```toml
//! [dependencies]
//! cratestack = { package = "cratestack-pg", version = "0.4" }
//! ```
//!
//! `sqlx`/`cratestack-sqlx` sit behind the default-on `postgres` Cargo
//! feature (cratestack#329). A `db = None`-only consumer
//! (`include_server_schema!(schema, db = None)`, cratestack#328) can drop
//! `sqlx` from its dependency graph entirely:
//!
//! ```toml
//! [dependencies]
//! cratestack = { package = "cratestack-pg", version = "0.4", default-features = false }
//! ```
//!
//! See `docs/design/no-database-mode.md` for when `db = None` applies and
//! what it gives up.
// Both `cratestack_core` and `cratestack_axum` expose `codec` and
// `transport` modules, and the facade re-exports both crates with a glob.
// The overlap is intentional — consumers reach those via the originating
// crate's path, not the facade root — so silence the ambiguity warning
// rather than dropping either glob.
// Re-exported so the axum dispatch tokens `cratestack-macros` generates
// for `@stream` procedures (`crate::axum::procedure::invoke_call`) can
// reference `::cratestack::async_stream::stream!` without every
// consumer adding `async-stream` to their own `Cargo.toml`. Needed
// because the `ProcedureRegistry` trait method's `db`/`ctx` parameters
// are borrowed (`&Cratestack`/`&CoolContext`), and — per return-position
// `impl Trait` in traits' default lifetime-capture rules — the returned
// `Stream` is only valid as long as those borrows are; wrapping the
// call in a self-contained `async_stream::stream!` generator that owns
// `db`/`ctx`/`registry`/`args` internally is what lets the resulting
// `Stream` outlive the dispatch function's own stack frame (needed
// since it travels all the way into the HTTP response body). Mirrors
// how `futures` is re-exported below for the same
// "codegen references a fixed path, consumers shouldn't have to
// duplicate the dependency" reason.
pub use async_stream;
pub use chrono;
pub use cratestack_client_rust as client_rust;
pub use *;
// Re-exported (renamed from the `futures-util` crate, which is what
// actually implements it) so `@stream` procedures' generated
// `ProcedureRegistry` trait method — `impl ::cratestack::futures::Stream<
// Item = Result<T, CoolError>> + Send` (see
// `cratestack-macros/src/procedure.rs`) — has somewhere to point without
// every consumer adding its own `futures`/`futures-core`/`futures-util`
// dependency. Mirrors how `chrono`/`uuid` are re-exported above for the
// same "codegen references a fixed path, consumers shouldn't have to
// duplicate the dependency" reason.
pub use ;
pub use ;
pub use ;
pub use futures_util as futures;
// SQL primitives shared by every backend — re-exported directly from
// `cratestack-sql` so consumers don't transit through `cratestack-sqlx`.
pub use ;
pub use regex;
pub use serde;
pub use serde_json;
pub use tracing;
pub use uuid;
// `Json<T>` resolves to `cratestack_sqlx::Json<T>` on the server so
// `sqlx::FromRow` decodes Postgres `jsonb` columns into it directly, using
// the plain/untagged codec (cratestack#162) rather than `T`'s own
// (externally-tagged, for `T = Value`) `Serialize`/`Deserialize`. This is
// only possible with the `postgres` feature enabled (cratestack#329): models
// (the only place a "Json" column is decoded from a row) can never exist
// under `db = None` (cratestack#327's guard), so a `postgres`-disabled build
// falls back to `cratestack-core`'s own backend-agnostic `Json<T>` newtype,
// which is all a `db = None` schema's procedure args/returns ever need —
// they only flow through serde (JSON/CBOR codecs), never `sqlx::FromRow`.
pub use Json;
pub use Json;
// `Vector(n)` model fields decode/encode through `pgvector::Vector` at
// the sqlx boundary (see `cratestack-macros`' generated `FromRow` impl
// and `SqlValue::Vector` bind path) — re-exported so macro-emitted
// `::cratestack::pgvector::Vector` paths resolve. Requires this
// facade's own `pgvector` feature, which forwards to both
// `cratestack-macros/pgvector` (the compile-time declaration gate)
// and `cratestack-sqlx/pgvector` (the real column codec) in lockstep.
pub use pgvector;
// -----------------------------------------------------------------------------
// Server surface — axum, audit/idempotency/migrations/isolation.
// -----------------------------------------------------------------------------
pub use axum;
pub use *;
// `transport grpc` server runtime (ticket #171) — only present when the
// consumer opts into the `grpc` Cargo feature (`cratestack-macros/src/
// include/server/grpc/` emits `::cratestack::grpc::...` paths that resolve
// here). A `transport grpc` schema without the feature enabled fails
// `include_server_schema!` with a `compile_error!` pointing at this
// feature — see `crates/cratestack-macros/src/include/reject_grpc.rs`.
// Disambiguate the `rpc` module path. Both `cratestack_core` (wire shapes)
// and `cratestack_axum` (binding helpers) expose an `rpc` module, so the
// two `pub use ..::*` globs collide on the name and `::cratestack::rpc::*`
// resolves non-deterministically. Macro-emitted code in `transport rpc`
// schemas references symbols like `encode_rpc_error`,
// `convert_handler_error_response`, `response_to_frame`, and
// `RPC_BINDING_CAPABILITIES` — all of which live in `cratestack-axum::rpc`.
// An explicit `pub use` re-export takes precedence over the globs, pinning
// `::cratestack::rpc` to the axum module (which itself re-exports the wire
// types from `cratestack-core::rpc`).
pub use rpc;
// Everything below is sqlx (Postgres)-backed and only compiled in when the
// default-on `postgres` feature is enabled (cratestack#329). A `db = None`
// -only consumer builds with `default-features = false` (or explicitly
// disables `postgres`) to drop `sqlx`/`cratestack-sqlx` from its dependency
// graph entirely — nothing generated under `db = None` ever references these
// symbols, since models (the only consumers of them) can never exist in a
// `datasource { provider = "none" }` schema.
pub use AUDIT_TABLE_DDL;
pub use sqlx;
pub use ;
pub use ;
pub use ;
/// Crypto provider selection for FIPS-validated deployments.
///
/// **`crypto-aws-lc-rs` is not implemented yet.** Enabling it is a hard
/// `compile_error!`, not a working FIPS mode — this used to return `Ok(())`
/// without installing any provider, which is a false assurance in a
/// compliance-facing API: a service that called this and checked for `Ok`
/// got an affirmative return while still running on the non-FIPS `ring`
/// backend. See <https://github.com/cratestack/cratestack/issues/334>.
///
/// Making this real requires the TLS backend becoming a genuine choice
/// across `cratestack-sqlx` and `cratestack-client-rust` (both currently
/// hard-select `ring`), not just adding `aws-lc-rs` as a dependency here —
/// Cargo features are additive, so enabling `crypto-aws-lc-rs` today would
/// only add a second provider alongside `ring`, not replace it. Until that
/// backend-selection work lands, this function fails to compile under the
/// feature rather than silently lying about what it installed.