systemprompt_identifiers/
execution.rs1use crate::{DbValue, ToDbValue};
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6use std::fmt;
7
8#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
9#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
10#[cfg_attr(feature = "sqlx", sqlx(transparent))]
11#[serde(transparent)]
12pub struct ExecutionStepId(String);
13
14impl ExecutionStepId {
15 pub fn new(id: impl Into<String>) -> Self {
16 Self(id.into())
17 }
18
19 pub fn generate() -> Self {
20 Self(uuid::Uuid::new_v4().to_string())
21 }
22
23 pub fn as_str(&self) -> &str {
24 &self.0
25 }
26}
27
28impl fmt::Display for ExecutionStepId {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 write!(f, "{}", self.0)
31 }
32}
33
34impl From<String> for ExecutionStepId {
35 fn from(s: String) -> Self {
36 Self(s)
37 }
38}
39
40impl From<&str> for ExecutionStepId {
41 fn from(s: &str) -> Self {
42 Self(s.to_string())
43 }
44}
45
46impl AsRef<str> for ExecutionStepId {
47 fn as_ref(&self) -> &str {
48 &self.0
49 }
50}
51
52impl ToDbValue for ExecutionStepId {
53 fn to_db_value(&self) -> DbValue {
54 DbValue::String(self.0.clone())
55 }
56}
57
58impl ToDbValue for &ExecutionStepId {
59 fn to_db_value(&self) -> DbValue {
60 DbValue::String(self.0.clone())
61 }
62}
63
64#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
65#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
66#[cfg_attr(feature = "sqlx", sqlx(transparent))]
67#[serde(transparent)]
68pub struct LogId(String);
69
70impl LogId {
71 pub fn new(id: impl Into<String>) -> Self {
72 Self(id.into())
73 }
74
75 pub fn generate() -> Self {
76 Self(uuid::Uuid::new_v4().to_string())
77 }
78
79 pub fn as_str(&self) -> &str {
80 &self.0
81 }
82}
83
84impl fmt::Display for LogId {
85 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
86 write!(f, "{}", self.0)
87 }
88}
89
90impl From<String> for LogId {
91 fn from(s: String) -> Self {
92 Self(s)
93 }
94}
95
96impl From<&str> for LogId {
97 fn from(s: &str) -> Self {
98 Self(s.to_string())
99 }
100}
101
102impl AsRef<str> for LogId {
103 fn as_ref(&self) -> &str {
104 &self.0
105 }
106}
107
108impl ToDbValue for LogId {
109 fn to_db_value(&self) -> DbValue {
110 DbValue::String(self.0.clone())
111 }
112}
113
114impl ToDbValue for &LogId {
115 fn to_db_value(&self) -> DbValue {
116 DbValue::String(self.0.clone())
117 }
118}
119
120#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
121#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
122#[cfg_attr(feature = "sqlx", sqlx(transparent))]
123#[serde(transparent)]
124pub struct TokenId(String);
125
126impl TokenId {
127 pub fn new(id: impl Into<String>) -> Self {
128 Self(id.into())
129 }
130
131 pub fn generate() -> Self {
132 Self(uuid::Uuid::new_v4().to_string())
133 }
134
135 pub fn as_str(&self) -> &str {
136 &self.0
137 }
138}
139
140impl fmt::Display for TokenId {
141 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
142 write!(f, "{}", self.0)
143 }
144}
145
146impl From<String> for TokenId {
147 fn from(s: String) -> Self {
148 Self(s)
149 }
150}
151
152impl From<&str> for TokenId {
153 fn from(s: &str) -> Self {
154 Self(s.to_string())
155 }
156}
157
158impl AsRef<str> for TokenId {
159 fn as_ref(&self) -> &str {
160 &self.0
161 }
162}
163
164impl ToDbValue for TokenId {
165 fn to_db_value(&self) -> DbValue {
166 DbValue::String(self.0.clone())
167 }
168}
169
170impl ToDbValue for &TokenId {
171 fn to_db_value(&self) -> DbValue {
172 DbValue::String(self.0.clone())
173 }
174}
175
176#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
177#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
178#[cfg_attr(feature = "sqlx", sqlx(transparent))]
179#[serde(transparent)]
180pub struct ArtifactId(String);
181
182impl ArtifactId {
183 pub fn new(id: impl Into<String>) -> Self {
184 Self(id.into())
185 }
186
187 pub fn generate() -> Self {
188 Self(uuid::Uuid::new_v4().to_string())
189 }
190
191 pub fn as_str(&self) -> &str {
192 &self.0
193 }
194}
195
196impl fmt::Display for ArtifactId {
197 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
198 write!(f, "{}", self.0)
199 }
200}
201
202impl From<String> for ArtifactId {
203 fn from(s: String) -> Self {
204 Self(s)
205 }
206}
207
208impl From<&str> for ArtifactId {
209 fn from(s: &str) -> Self {
210 Self(s.to_string())
211 }
212}
213
214impl AsRef<str> for ArtifactId {
215 fn as_ref(&self) -> &str {
216 &self.0
217 }
218}
219
220impl ToDbValue for ArtifactId {
221 fn to_db_value(&self) -> DbValue {
222 DbValue::String(self.0.clone())
223 }
224}
225
226impl ToDbValue for &ArtifactId {
227 fn to_db_value(&self) -> DbValue {
228 DbValue::String(self.0.clone())
229 }
230}
231
232impl From<ArtifactId> for String {
233 fn from(id: ArtifactId) -> Self {
234 id.0
235 }
236}
237
238impl From<&ArtifactId> for String {
239 fn from(id: &ArtifactId) -> Self {
240 id.0.clone()
241 }
242}
243
244impl PartialEq<&str> for ArtifactId {
245 fn eq(&self, other: &&str) -> bool {
246 self.0 == *other
247 }
248}
249
250impl std::borrow::Borrow<str> for ArtifactId {
251 fn borrow(&self) -> &str {
252 &self.0
253 }
254}