From 349aeef06f0dd06e2170943d162da651012142c2 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 25 Oct 2026 17:50:06 +0800 Subject: [PATCH] =?UTF-8?q?docs(spec):=20=E8=A7=84=E6=A0=BC=20=C2=A79=20?= =?UTF-8?q?=E5=AF=B9=E9=BD=90=20pglite::Error=20=E4=B8=8E=20state.rs?= =?UTF-8?q?=EF=BC=9Brelease=20=E5=8E=BB=E6=8E=89=20panic=3Dabort?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - §9 crud.rs 三个签名统一成 `pglite::Error`(原写的 `DbError` 未定义) - §9 lib.rs 清单补 `pub mod state;`(Ruling P14:AppState 归 state.rs,Task 4 是 lib.rs 唯一写入者) - 根 Cargo.toml 去掉 `[profile.release] panic = "abort"`: 规格 §6.5 要求 panic ⇒ HTTP 200 + code=400,而 abort 下 catch_unwind 抓不到 panic(进程直接死 ⇒ 客户端连接重置)。catch-all 中间件依赖默认 unwind。 Co-Authored-By: Claude Code --- Cargo.toml | 4 +++- docs/contract.md | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 01d20d2..e938a0d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,5 +40,7 @@ chrono = "0.4" opt-level = 2 lto = "thin" strip = "symbols" -panic = "abort" +# 🔴 不要设 `panic = "abort"`:规格 §6.5 要求 panic ⇒ HTTP 200 + code=400, +# 而 abort 下 `catch_unwind` 抓不到 panic(进程直接死 ⇒ 客户端连接重置)。 +# catch-all 中间件依赖默认的 `panic = "unwind"`(Ruling P19)。 codegen-units = 16 diff --git a/docs/contract.md b/docs/contract.md index 4228a3a..c0548fa 100644 --- a/docs/contract.md +++ b/docs/contract.md @@ -723,6 +723,7 @@ SELECT row_to_json(q)::text AS _row FROM () AS q ```rust // ---- lib.rs ---- +pub mod auth; pub mod cipher; pub mod config; pub mod crud; @@ -734,8 +735,8 @@ pub mod permission; pub mod routes; pub mod seed; pub mod session; +pub mod state; // 🔴 由 Task 4 追加(全仓只有 Task 4 能改 lib.rs) pub mod sys; -pub mod auth; ``` ### ids.rs @@ -829,9 +830,9 @@ pub fn find_spec(app_code: &str, entity: &str) -> Option<&'static EntitySpec>; ### crud.rs(spec 驱动的通用 CRUD) ```rust -pub async fn list(db: &Db, spec: &EntitySpec) -> Result, DbError>; -pub async fn save(db: &Db, spec: &EntitySpec, body: &Value) -> Result; -pub async fn remove(db: &Db, spec: &EntitySpec, id: &str) -> Result<(), DbError>; +pub async fn list(db: &Db, spec: &EntitySpec) -> Result, pglite::Error>; +pub async fn save(db: &Db, spec: &EntitySpec, body: &Value) -> Result; +pub async fn remove(db: &Db, spec: &EntitySpec, id: &str) -> Result<(), pglite::Error>; ``` ### routes.rs