summaryrefslogtreecommitdiffstats
path: root/src/db/model/state.rs
diff options
context:
space:
mode:
authordev <dev@localhost>2026-11-20 17:26:52 +0000
committerdev <dev@localhost>2026-11-20 17:26:52 +0000
commit154f6f6dd284c11da82cf1188ff8549db6459228 (patch)
tree484edb3f9a77156df8dce7c2f3acaf443b014f89 /src/db/model/state.rs
parent8cd32e5309b14f5264813e5f2ce6ecdb5aa41fb4 (diff)
downloadaur-build-154f6f6dd284c11da82cf1188ff8549db6459228.tar.gz
aur-build-154f6f6dd284c11da82cf1188ff8549db6459228.zip
db: close what nothing reaches, and say what cannot be closed
db handed out 226 items and 36 of them were named by nobody at all — not by the crate, not by the tests. Making them private is the whole of this commit, but the interesting part is what the compiler said afterwards. Twenty-five closed cleanly. Eleven did not, and they are the ones worth writing down: AuditRow, NoticeRow, PackageRow, Subscription, StepRow, Unbuilt, OpenReview, ReviewSubject, Migration, Writer, predecessors. None is named outside db, yet none can be made private, because a public query returns them and callers bind them with `let` and call methods on them. They are load-bearing and invisible to a name search. So the census's `dead` count means "the name is never written outside the module", which is a lead rather than a verdict, and the census now says so: the way to find out which flagged items are real is to privatize them and let rustc answer. Those eleven are budgeted with that reason, not zeroed to make a number look good. Nineteen items turned out to be dead code rather than merely unexported — set_release, set_candidate, set_pkgbase, set_profile, set_kind, current_state, index_pkgbase_drift, wal_stats, call_for_tests, put_notice, is_ours, list_pkgbases, set_unpinable, artifact_id_by_digest_in, subscription_poll_interval, the four never-emitted notice kinds, and StateEnum::as_str, which the impl_state_enum macro was required to define for all five enums while nothing called it through the trait. Privatizing is what proved they were unused; leaving them private-but-present would have just hidden dead code behind a narrower address. Ten items became pub(crate): the Writer actor's call/tx/send surface, Readers, the StateEnum trait, json_or, predecessors, DEFAULT_SETTINGS. `Db.readers` was named nowhere outside db, so the field closed with the type. db: 226 pub / 36 dead-only -> 201 pub / 11 dead-only. 277 passed / 0 failed, clippy -D warnings clean, schema_ownership and architecture green.
Diffstat (limited to 'src/db/model/state.rs')
-rw-r--r--src/db/model/state.rs12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/db/model/state.rs b/src/db/model/state.rs
index 4882428..777840f 100644
--- a/src/db/model/state.rs
+++ b/src/db/model/state.rs
@@ -53,7 +53,7 @@ impl CandidateState {
}
}
- pub fn predecessors(to: CandidateState) -> Vec<&'static str> {
+ pub(crate) fn predecessors(to: CandidateState) -> Vec<&'static str> {
CandidateState::ALL
.iter()
.filter(|from| from.can_transition(to))
@@ -118,10 +118,9 @@ impl std::fmt::Display for ReleaseState {
}
}
-pub trait StateEnum: Copy + Sized {
+pub(crate) trait StateEnum: Copy + Sized {
const KIND: &'static str;
fn parse(text: &str) -> Option<Self>;
- fn as_str(&self) -> &'static str;
}
macro_rules! impl_state_enum {
@@ -131,9 +130,6 @@ macro_rules! impl_state_enum {
fn parse(text: &str) -> Option<Self> {
<$t>::parse(text)
}
- fn as_str(&self) -> &'static str {
- <$t>::as_str(self)
- }
}
};
}
@@ -147,12 +143,8 @@ impl_state_enum!(SubscriptionState, "subscription");
pub mod notice_kind {
pub const PIN_DRIFT: &str = "pin_drift";
pub const RECIPE_DRIFT: &str = "recipe_drift";
- pub const DIGEST_DRIFT: &str = "digest_drift";
pub const INTEGRITY_ALERT: &str = "integrity_alert";
- pub const UNPINABLE_PKGVER: &str = "unpinable_pkgver";
- pub const ORPHANED: &str = "orphaned";
pub const DELETED: &str = "deleted";
- pub const RENAMED: &str = "renamed";
pub const DOWNGRADE: &str = "downgrade";
}