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:
parent
084e12503c
commit
f74c1984d7
4 changed files with 25 additions and 35 deletions
|
|
@ -250,6 +250,24 @@ pub enum ApprovalKind {
|
|||
MergeConfigPr,
|
||||
}
|
||||
|
||||
impl ApprovalKind {
|
||||
/// Wire/UI string — the same value serde's `snake_case` rename
|
||||
/// produces. The single source of truth for every place that needs
|
||||
/// the kind as a `&'static str` (sqlite storage, dashboard events),
|
||||
/// so adding a variant can't silently miss a hand-rolled match.
|
||||
#[must_use]
|
||||
pub fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
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",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ApprovalStatus {
|
||||
|
|
|
|||
Loading…
Reference in a new issue