refactor: ApprovalKind::as_str owns the kind→string mapping

replaces three hand-rolled six-arm matches (actions.rs ×2,
state_snapshot.rs); approvals::kind_to_str delegates. a new kind can
no longer silently miss one of them
This commit is contained in:
müde 2026-07-06 21:48:55 +02:00
commit f74c1984d7
4 changed files with 25 additions and 35 deletions

View file

@ -411,18 +411,11 @@ fn row_to_approval(row: &rusqlite::Row<'_>) -> rusqlite::Result<Approval> {
}
/// Stable kind→str mapping used wherever we emit `ApprovalResolved`
/// or persist a kind to sqlite. `pub(crate)` so callers like
/// `questions::handle_cancel_loose_end` don't have to duplicate the
/// match; bumping a kind here is the single source of truth.
/// or persist a kind to sqlite. Thin alias over
/// [`ApprovalKind::as_str`] (the wire-type owns the mapping) kept for
/// the existing call sites' name.
pub(crate) fn kind_to_str(kind: ApprovalKind) -> &'static str {
match kind {
ApprovalKind::ApplyCommit => "apply_commit",
ApprovalKind::Spawn => "spawn",
ApprovalKind::InitConfig => "init_config",
ApprovalKind::UpdateMetaInputs => "update_meta_inputs",
ApprovalKind::SchedulePrompt => "schedule_prompt",
ApprovalKind::MergeConfigPr => "merge_config_pr",
}
kind.as_str()
}
fn kind_from_str(s: &str) -> Result<ApprovalKind> {