systemprompt_identifiers/
content.rs1use crate::{DbValue, ToDbValue};
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4use std::fmt;
5
6#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
7#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
8#[cfg_attr(feature = "sqlx", sqlx(transparent))]
9#[serde(transparent)]
10pub struct SkillId(String);
11
12impl SkillId {
13 pub fn new(id: impl Into<String>) -> Self {
14 Self(id.into())
15 }
16
17 pub fn generate() -> Self {
18 Self(uuid::Uuid::new_v4().to_string())
19 }
20
21 pub fn as_str(&self) -> &str {
22 &self.0
23 }
24}
25
26impl fmt::Display for SkillId {
27 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28 write!(f, "{}", self.0)
29 }
30}
31
32impl From<String> for SkillId {
33 fn from(s: String) -> Self {
34 Self(s)
35 }
36}
37
38impl From<&str> for SkillId {
39 fn from(s: &str) -> Self {
40 Self(s.to_string())
41 }
42}
43
44impl AsRef<str> for SkillId {
45 fn as_ref(&self) -> &str {
46 &self.0
47 }
48}
49
50impl ToDbValue for SkillId {
51 fn to_db_value(&self) -> DbValue {
52 DbValue::String(self.0.clone())
53 }
54}
55
56impl ToDbValue for &SkillId {
57 fn to_db_value(&self) -> DbValue {
58 DbValue::String(self.0.clone())
59 }
60}
61
62impl From<SkillId> for String {
63 fn from(id: SkillId) -> Self {
64 id.0
65 }
66}
67
68impl From<&SkillId> for String {
69 fn from(id: &SkillId) -> Self {
70 id.0.clone()
71 }
72}
73
74impl PartialEq<&str> for SkillId {
75 fn eq(&self, other: &&str) -> bool {
76 self.0 == *other
77 }
78}
79
80impl std::borrow::Borrow<str> for SkillId {
81 fn borrow(&self) -> &str {
82 &self.0
83 }
84}
85
86#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
87#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
88#[cfg_attr(feature = "sqlx", sqlx(transparent))]
89#[serde(transparent)]
90pub struct SourceId(String);
91
92impl SourceId {
93 pub fn new(id: impl Into<String>) -> Self {
94 Self(id.into())
95 }
96
97 pub fn as_str(&self) -> &str {
98 &self.0
99 }
100}
101
102impl fmt::Display for SourceId {
103 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
104 write!(f, "{}", self.0)
105 }
106}
107
108impl From<String> for SourceId {
109 fn from(s: String) -> Self {
110 Self(s)
111 }
112}
113
114impl From<&str> for SourceId {
115 fn from(s: &str) -> Self {
116 Self(s.to_string())
117 }
118}
119
120impl AsRef<str> for SourceId {
121 fn as_ref(&self) -> &str {
122 &self.0
123 }
124}
125
126impl ToDbValue for SourceId {
127 fn to_db_value(&self) -> DbValue {
128 DbValue::String(self.0.clone())
129 }
130}
131
132impl ToDbValue for &SourceId {
133 fn to_db_value(&self) -> DbValue {
134 DbValue::String(self.0.clone())
135 }
136}
137
138impl From<SourceId> for String {
139 fn from(id: SourceId) -> Self {
140 id.0
141 }
142}
143
144impl From<&SourceId> for String {
145 fn from(id: &SourceId) -> Self {
146 id.0.clone()
147 }
148}
149
150impl PartialEq<&str> for SourceId {
151 fn eq(&self, other: &&str) -> bool {
152 self.0 == *other
153 }
154}
155
156impl std::borrow::Borrow<str> for SourceId {
157 fn borrow(&self) -> &str {
158 &self.0
159 }
160}
161
162#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
163#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
164#[cfg_attr(feature = "sqlx", sqlx(transparent))]
165#[serde(transparent)]
166pub struct CategoryId(String);
167
168impl CategoryId {
169 pub fn new(id: impl Into<String>) -> Self {
170 Self(id.into())
171 }
172
173 pub fn as_str(&self) -> &str {
174 &self.0
175 }
176}
177
178impl fmt::Display for CategoryId {
179 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
180 write!(f, "{}", self.0)
181 }
182}
183
184impl From<String> for CategoryId {
185 fn from(s: String) -> Self {
186 Self(s)
187 }
188}
189
190impl From<&str> for CategoryId {
191 fn from(s: &str) -> Self {
192 Self(s.to_string())
193 }
194}
195
196impl AsRef<str> for CategoryId {
197 fn as_ref(&self) -> &str {
198 &self.0
199 }
200}
201
202impl ToDbValue for CategoryId {
203 fn to_db_value(&self) -> DbValue {
204 DbValue::String(self.0.clone())
205 }
206}
207
208impl ToDbValue for &CategoryId {
209 fn to_db_value(&self) -> DbValue {
210 DbValue::String(self.0.clone())
211 }
212}
213
214impl From<CategoryId> for String {
215 fn from(id: CategoryId) -> Self {
216 id.0
217 }
218}
219
220impl From<&CategoryId> for String {
221 fn from(id: &CategoryId) -> Self {
222 id.0.clone()
223 }
224}
225
226impl PartialEq<&str> for CategoryId {
227 fn eq(&self, other: &&str) -> bool {
228 self.0 == *other
229 }
230}
231
232impl std::borrow::Borrow<str> for CategoryId {
233 fn borrow(&self) -> &str {
234 &self.0
235 }
236}
237
238#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
239#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
240#[cfg_attr(feature = "sqlx", sqlx(transparent))]
241#[serde(transparent)]
242pub struct ContentId(String);
243
244impl ContentId {
245 pub fn new(id: impl Into<String>) -> Self {
246 Self(id.into())
247 }
248
249 pub fn as_str(&self) -> &str {
250 &self.0
251 }
252}
253
254impl fmt::Display for ContentId {
255 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
256 write!(f, "{}", self.0)
257 }
258}
259
260impl From<String> for ContentId {
261 fn from(s: String) -> Self {
262 Self(s)
263 }
264}
265
266impl From<&str> for ContentId {
267 fn from(s: &str) -> Self {
268 Self(s.to_string())
269 }
270}
271
272impl AsRef<str> for ContentId {
273 fn as_ref(&self) -> &str {
274 &self.0
275 }
276}
277
278impl ToDbValue for ContentId {
279 fn to_db_value(&self) -> DbValue {
280 DbValue::String(self.0.clone())
281 }
282}
283
284impl ToDbValue for &ContentId {
285 fn to_db_value(&self) -> DbValue {
286 DbValue::String(self.0.clone())
287 }
288}
289
290#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
291#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
292#[cfg_attr(feature = "sqlx", sqlx(transparent))]
293#[serde(transparent)]
294pub struct TagId(String);
295
296impl TagId {
297 pub fn new(id: impl Into<String>) -> Self {
298 Self(id.into())
299 }
300
301 pub fn as_str(&self) -> &str {
302 &self.0
303 }
304}
305
306impl fmt::Display for TagId {
307 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
308 write!(f, "{}", self.0)
309 }
310}
311
312impl From<String> for TagId {
313 fn from(s: String) -> Self {
314 Self(s)
315 }
316}
317
318impl From<&str> for TagId {
319 fn from(s: &str) -> Self {
320 Self(s.to_string())
321 }
322}
323
324impl AsRef<str> for TagId {
325 fn as_ref(&self) -> &str {
326 &self.0
327 }
328}
329
330impl ToDbValue for TagId {
331 fn to_db_value(&self) -> DbValue {
332 DbValue::String(self.0.clone())
333 }
334}
335
336impl ToDbValue for &TagId {
337 fn to_db_value(&self) -> DbValue {
338 DbValue::String(self.0.clone())
339 }
340}
341
342#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
343#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
344#[cfg_attr(feature = "sqlx", sqlx(transparent))]
345#[serde(transparent)]
346pub struct FileId(String);
347
348impl FileId {
349 pub fn new(id: impl Into<String>) -> Self {
350 Self(id.into())
351 }
352
353 pub fn generate() -> Self {
354 Self(uuid::Uuid::new_v4().to_string())
355 }
356
357 pub fn as_str(&self) -> &str {
358 &self.0
359 }
360}
361
362impl fmt::Display for FileId {
363 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
364 write!(f, "{}", self.0)
365 }
366}
367
368impl From<String> for FileId {
369 fn from(s: String) -> Self {
370 Self(s)
371 }
372}
373
374impl From<&str> for FileId {
375 fn from(s: &str) -> Self {
376 Self(s.to_string())
377 }
378}
379
380impl AsRef<str> for FileId {
381 fn as_ref(&self) -> &str {
382 &self.0
383 }
384}
385
386impl ToDbValue for FileId {
387 fn to_db_value(&self) -> DbValue {
388 DbValue::String(self.0.clone())
389 }
390}
391
392impl ToDbValue for &FileId {
393 fn to_db_value(&self) -> DbValue {
394 DbValue::String(self.0.clone())
395 }
396}