titanium_model/builder/
role.rs1use crate::TitanString;
2
3#[derive(Debug, Clone, serde::Serialize, Default)]
5pub struct CreateRole<'a> {
6 #[serde(skip_serializing_if = "Option::is_none")]
7 pub name: Option<TitanString<'a>>,
8 #[serde(skip_serializing_if = "Option::is_none")]
9 pub permissions: Option<String>,
10 #[serde(skip_serializing_if = "Option::is_none")]
11 pub color: Option<u32>,
12 #[serde(skip_serializing_if = "Option::is_none")]
13 pub hoist: Option<bool>,
14 #[serde(skip_serializing_if = "Option::is_none")]
15 pub icon: Option<TitanString<'a>>,
16 #[serde(skip_serializing_if = "Option::is_none")]
17 pub unicode_emoji: Option<TitanString<'a>>,
18 #[serde(skip_serializing_if = "Option::is_none")]
19 pub mentionable: Option<bool>,
20}
21
22#[derive(Debug, Clone, Default)]
24pub struct CreateRoleBuilder<'a> {
25 params: CreateRole<'a>,
26}
27
28impl<'a> CreateRoleBuilder<'a> {
29 #[must_use]
30 pub fn new() -> Self {
31 Self::default()
32 }
33
34 pub fn name(mut self, name: impl Into<TitanString<'a>>) -> Self {
35 self.params.name = Some(name.into());
36 self
37 }
38
39 #[must_use]
40 pub fn color(mut self, color: u32) -> Self {
41 self.params.color = Some(color);
42 self
43 }
44
45 #[must_use]
46 pub fn hoist(mut self, hoist: bool) -> Self {
47 self.params.hoist = Some(hoist);
48 self
49 }
50
51 pub fn icon(mut self, icon: impl Into<TitanString<'a>>) -> Self {
52 self.params.icon = Some(icon.into());
53 self
54 }
55
56 pub fn unicode_emoji(mut self, emoji: impl Into<TitanString<'a>>) -> Self {
57 self.params.unicode_emoji = Some(emoji.into());
58 self
59 }
60
61 #[must_use]
62 pub fn mentionable(mut self, mentionable: bool) -> Self {
63 self.params.mentionable = Some(mentionable);
64 self
65 }
66
67 #[must_use]
68 pub fn build(self) -> CreateRole<'a> {
69 self.params
70 }
71}