1use serde::{Deserialize, Serialize};
9use std::fmt;
10use std::str::FromStr;
11
12#[derive(
14 Debug, Clone, Copy, Default, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash,
15)]
16#[serde(rename_all = "lowercase")]
17pub enum Bump {
18 #[default]
20 None,
21 Patch,
23 Minor,
25 Major,
27}
28
29impl fmt::Display for Bump {
30 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
31 formatter.write_str(match self {
32 Self::None => "none",
33 Self::Patch => "patch",
34 Self::Minor => "minor",
35 Self::Major => "major",
36 })
37 }
38}
39
40impl FromStr for Bump {
41 type Err = String;
42
43 fn from_str(value: &str) -> std::result::Result<Self, Self::Err> {
44 match value {
45 "patch" => Ok(Self::Patch),
46 "minor" => Ok(Self::Minor),
47 "major" => Ok(Self::Major),
48 _ => Err(format!("expected major, minor, or patch; got {value}")),
49 }
50 }
51}
52
53#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
55#[serde(rename_all = "lowercase")]
56pub enum ProjectionMode {
57 Committed,
59 Injected,
61 None,
63}
64
65#[derive(Debug, Clone, Copy, Default, Deserialize, Serialize, PartialEq, Eq)]
71#[serde(rename_all = "lowercase")]
72pub enum BumpTranslation {
73 #[default]
75 Parity,
76 Significance,
78}
79
80impl fmt::Display for BumpTranslation {
81 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
82 formatter.write_str(match self {
83 Self::Parity => "parity",
84 Self::Significance => "significance",
85 })
86 }
87}
88
89impl FromStr for BumpTranslation {
90 type Err = String;
91
92 fn from_str(value: &str) -> std::result::Result<Self, Self::Err> {
93 match value {
94 "parity" => Ok(Self::Parity),
95 "significance" => Ok(Self::Significance),
96 _ => Err(format!("expected parity or significance; got {value}")),
97 }
98 }
99}
100
101#[derive(Debug, Clone, Copy, Default, Deserialize, Serialize, PartialEq, Eq)]
103#[serde(rename_all = "lowercase")]
104pub enum ReleaseUnitDisposition {
105 #[default]
107 Managed,
108 Suspended,
110}
111
112#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
114#[serde(rename_all = "lowercase")]
115pub enum TagRole {
116 Primary,
118 Projection,
120}
121
122#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
124#[serde(rename_all = "kebab-case")]
125pub enum TagPhase {
126 BeforePublication,
128 AfterPublication,
130}
131
132impl fmt::Display for TagPhase {
133 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
134 formatter.write_str(match self {
135 Self::BeforePublication => "before-publication",
136 Self::AfterPublication => "after-publication",
137 })
138 }
139}
140
141#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, Hash)]
143#[serde(rename_all = "lowercase")]
144pub enum Adapter {
145 Npm,
147 Cargo,
149 Pub,
151 Python,
153 Msbuild,
155 Go,
157 Json,
159 Toml,
161 Yaml,
163}
164
165impl Adapter {
166 pub fn requires_pointer(self) -> bool {
168 matches!(self, Self::Json | Self::Toml | Self::Yaml)
169 }
170
171 pub fn ecosystem(self) -> Option<&'static str> {
173 match self {
174 Self::Npm => Some("npm"),
175 Self::Cargo => Some("cargo"),
176 Self::Pub => Some("pub"),
177 Self::Python => Some("python"),
178 Self::Msbuild => Some("msbuild"),
179 Self::Go => Some("go"),
180 Self::Json | Self::Toml | Self::Yaml => None,
181 }
182 }
183}