From 0f18ebddc1c138c531e3e331786c7fa917d9186f Mon Sep 17 00:00:00 2001 From: dev Date: Sat, 21 Nov 2026 19:27:26 +0000 Subject: http: ten request and response helpers were never crate-internal, just unmarked `http` declares 81 `pub(crate)` items, the densest cluster in the tree, and the census called every one of them the good state. Ten of them are not crate-internal at all: `State`, `Req`, `Res`, `logout`, and the five accessors on `Req` and constructors on `Res` are named only from `http/mod.rs`, the file that declares them. The router dispatches through them in the same file; the `pub(crate)` was describing an outside caller that does not exist. `cookie` is the one worth naming: it is the auth-cookie helper, it looked used from `http/routes/mod.rs`, and what is used there is a *field* named `cookie` on `Req`. A word-match census cannot tell those apart, which is the whole reason this pass was done by stripping markers and compiling rather than by reading the census output. priv 159 -> 149 (http 81 -> 71), overwide 22 -> 21. `cargo check` clean under both profiles, no new warnings; tests/http.rs, surfaces.rs, notices.rs and invariants.rs all pass (43 tests). --- src/http/mod.rs | 18 +++++++++--------- src/http/routes/mod.rs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/http') diff --git a/src/http/mod.rs b/src/http/mod.rs index c95cd16..f10d4e2 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -9,12 +9,12 @@ use std::sync::Arc; use crate::config::Config; use crate::db::Db; -pub(crate) struct State { +struct State { pub cfg: Config, pub db: Db, } -pub(crate) struct Req { +struct Req { pub method: String, pub path: String, pub cookies: Vec<(String, String)>, @@ -25,13 +25,13 @@ pub(crate) struct Req { impl Req { /// Read by the route handlers, which are in this module; the word `form` in a test is a local parameter. - pub(crate) fn form(&self) -> &[(String, String)] { + fn form(&self) -> &[(String, String)] { &self.form_pairs } - pub(crate) fn form_get(&self, key: &str) -> Option { + fn form_get(&self, key: &str) -> Option { self.form_pairs.iter().find(|(k, _)| k == key).map(|(_, v)| v.clone()) } - pub(crate) fn query_get(&self, key: &str) -> Option { + fn query_get(&self, key: &str) -> Option { self.query_pairs.iter().find(|(k, _)| k == key).map(|(_, v)| v.clone()) } /// Reading a cookie off a request is internal plumbing; the auth tests need it in order to forge one. @@ -44,7 +44,7 @@ impl Req { } #[cfg(not(feature = "test-support"))] - pub(crate) fn cookie(&self, name: &str) -> Option { + fn cookie(&self, name: &str) -> Option { Self::cookie_impl(self, name) } @@ -53,7 +53,7 @@ impl Req { } } -pub(crate) struct Res { +struct Res { pub status: u16, pub content_type: String, pub body: Vec, @@ -64,7 +64,7 @@ pub(crate) struct Res { impl Res { /// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it. - pub(crate) fn html(status: u16, body: String) -> Self { + fn html(status: u16, body: String) -> Self { Self { status, content_type: "text/html; charset=utf-8".into(), body: body.into_bytes(), headers: Vec::new(), stream: None, stream_len: None } } pub fn text(status: u16, body: String) -> Self { @@ -81,7 +81,7 @@ impl Res { } } /// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it. - pub(crate) fn redirect(location: &str) -> Self { + fn redirect(location: &str) -> Self { Self { status: 303, content_type: "text/plain".into(), diff --git a/src/http/routes/mod.rs b/src/http/routes/mod.rs index 0ffecb0..2b9ebb9 100644 --- a/src/http/routes/mod.rs +++ b/src/http/routes/mod.rs @@ -34,7 +34,7 @@ pub(crate) fn login_form(state: &State, req: &Req) -> Res { } /// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it. -pub(crate) fn logout(req: &Req) -> Res { +fn logout(req: &Req) -> Res { if let Some(sid) = req.cookie("sid") { auth::drop_session(&sid); } -- cgit v1.2.3