From 6c4b4394bd8ddf28d130e87e0100349f13f6e912 Mon Sep 17 00:00:00 2001 From: dev Date: Fri, 20 Nov 2026 18:49:22 +0000 Subject: foundation, http: export what is used above you, and nothing else MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The leaf modules were the widest liars. `git` exported 19 names of which 5 were named by nobody; `hash` exported a constant `EMPTY` that no code had ever referenced; `time` exported a virtual clock, an `advance` and a `wrap` whose only caller was a test that turned out not to exist. A leaf's interface is the whole contract the rest of the crate can rely on, and these interfaces were mostly decoration. Nine items were genuinely dead and are gone: `hash::EMPTY`, `git::{clone_source, count_commits, log_oneline, ls_remote_heads}`, `recipe::is_diffable`, `pkginfo::values_of`, `time::virtual_now`, and a free `time::advance` that had been shadowed by the `VirtualClock` method tests actually call. Eighteen more were used only inside their own module and are now private — `fetch`'s `Body` aside, which is the return type of a public parser and so is part of the interface whether or not anyone writes its name. http went 68 exported names to 27, and its last two glob re-exports (`pub(crate) use mutations::*; use pages::*;`) are explicit lists now. That makes the crate's glob count zero, so the allowlist in the architecture test is empty and can stay that way. Narrowing surfaced dead code that `pub` had been hiding, because a public item is presumed used and never questioned: `Req::query` and `Req::body` were parsed and stored and never read, `Res::found` had no callers, and `sse::FileBody` was a reader nobody constructed. All four are deleted rather than re-published to keep the warning quiet. git 19→14, hash 8→7, recipe 11→7, urlutil 2→1, config 35→31, pkgver 18→14, time 16→14, pkginfo 7→6, http 68→27. Crate totals: 585→516 pub, 219→115 dead, 4→0 globs. 281 passed / 0 failed, clippy -D warnings clean, release build clean, architecture 8/8. --- src/http/routes/mod.rs | 17 ++++++++++++----- src/http/routes/pages.rs | 8 ++++---- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src/http/routes') diff --git a/src/http/routes/mod.rs b/src/http/routes/mod.rs index ed488c8..7495524 100644 --- a/src/http/routes/mod.rs +++ b/src/http/routes/mod.rs @@ -8,10 +8,17 @@ use super::{Req, Res, State}; mod mutations; mod pages; -pub(crate) use mutations::*; -pub(crate) use pages::*; - -pub fn gate(state: &State, req: &Req, sid: &str) -> Option { +pub(crate) use mutations::{ + build_cancel, build_retry, notice_ack, package_rebuild, package_withdraw, review_approve, + review_reject, reviews_bulk, sub_add, sub_pause, sub_remove, +}; +pub(crate) use pages::{ + attention, audit, build_detail, build_log, build_log_stream, builds_page, builds_with, + dashboard, metrics, package_detail, packages, panels_base, review_body, review_detail, + review_rows, reviews, settings, subscriptions, +}; + +pub(crate) fn gate(state: &State, req: &Req, sid: &str) -> Option { if !auth::auth_required(&state.cfg) { return None; } @@ -21,7 +28,7 @@ pub fn gate(state: &State, req: &Req, sid: &str) -> Option { Some(Res::redirect("/login")) } -pub fn login_form(state: &State, req: &Req) -> Res { +pub(crate) fn login_form(state: &State, req: &Req) -> Res { let page = Page::new("Sign in", csrf(state, req)); page_to_res(Login { page, error: String::new() }, 200) } diff --git a/src/http/routes/pages.rs b/src/http/routes/pages.rs index bb5db34..e8590b0 100644 --- a/src/http/routes/pages.rs +++ b/src/http/routes/pages.rs @@ -70,7 +70,7 @@ pub(crate) fn reviews(state: &State, req: &Req) -> Res { page_to_res(ReviewsPage { page, rows: review_rows(&state.db) }, 200) } -pub(crate) fn full_version(c: &CandidateRow) -> String { +fn full_version(c: &CandidateRow) -> String { crate::pkgver::full_version(&c.epoch, &c.pkgver, &c.pkgrel) } @@ -368,7 +368,7 @@ pub(crate) fn package_detail(state: &State, req: &Req, name: &str) -> Res { // --------------------------------------------------------------- builds -- -pub(crate) fn build_version(db: &Db, b: &builds::BuildRow) -> String { +fn build_version(db: &Db, b: &builds::BuildRow) -> String { if let Some(cid) = b.candidate_id { if let Some(c) = candidates::candidate_by_id(db, cid).ok().flatten() { return c.version(); @@ -382,7 +382,7 @@ pub(crate) fn build_version(db: &Db, b: &builds::BuildRow) -> String { String::new() } -pub(crate) fn build_rows(state: &State) -> Vec { +fn build_rows(state: &State) -> Vec { builds::list( &state.db, BuildState::active(), @@ -424,7 +424,7 @@ pub(crate) fn builds_page(state: &State, req: &Req) -> Res { builds_with(state, req, page) } -pub(crate) fn recent_rows(state: &State) -> Vec { +fn recent_rows(state: &State) -> Vec { builds::list(&state.db, &[BuildState::Failed, BuildState::Succeeded], 10) .unwrap_or_default() .into_iter() -- cgit v1.2.3