systemprompt_identifiers/
roles.rs1use crate::{DbValue, ToDbValue};
4use serde::{Deserialize, Serialize};
5use std::fmt;
6
7#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
8#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
9#[cfg_attr(feature = "sqlx", sqlx(transparent))]
10#[serde(transparent)]
11pub struct RoleId(String);
12
13impl RoleId {
14 pub fn new(id: impl Into<String>) -> Self {
15 Self(id.into())
16 }
17
18 pub fn as_str(&self) -> &str {
19 &self.0
20 }
21}
22
23impl fmt::Display for RoleId {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 write!(f, "{}", self.0)
26 }
27}
28
29impl From<String> for RoleId {
30 fn from(s: String) -> Self {
31 Self(s)
32 }
33}
34
35impl From<&str> for RoleId {
36 fn from(s: &str) -> Self {
37 Self(s.to_string())
38 }
39}
40
41impl AsRef<str> for RoleId {
42 fn as_ref(&self) -> &str {
43 &self.0
44 }
45}
46
47impl ToDbValue for RoleId {
48 fn to_db_value(&self) -> DbValue {
49 DbValue::String(self.0.clone())
50 }
51}
52
53impl ToDbValue for &RoleId {
54 fn to_db_value(&self) -> DbValue {
55 DbValue::String(self.0.clone())
56 }
57}