1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
use crate::{builder_methods, serde_for_bitflags};
use serde::{Deserialize, Serialize};
#[cfg(feature = "openapi")]
use utoipa::ToSchema;
#[derive(Clone, Debug, Default, Serialize)]
#[cfg_attr(feature = "client", derive(Deserialize))]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub struct User {
pub id: u64,
pub username: String,
pub discriminator: u16,
pub avatar: Option<String>,
pub banner: Option<String>,
pub bio: Option<String>,
pub flags: UserFlags,
}
bitflags::bitflags! {
#[derive(Default)]
pub struct UserFlags: u32 {
const BOT = 1 << 0;
}
}
serde_for_bitflags!(u32: UserFlags);
impl User {
builder_methods! {
id: u64 => set_id,
username: String => set_username,
discriminator: u16 => set_discriminator,
avatar: String => set_avatar + Some,
banner: String => set_banner + Some,
bio: String => set_bio + Some,
flags: UserFlags => set_flags,
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub struct GuildFolderInfo {
pub name: String,
pub color: u32,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub struct GuildFolder {
pub path: Option<Vec<GuildFolderInfo>>,
pub guilds: Vec<u64>,
}
#[derive(Clone, Debug, Default, Serialize)]
#[cfg_attr(feature = "client", derive(Deserialize))]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub struct ClientUser {
#[serde(flatten)]
pub user: User,
#[cfg_attr(feature = "openapi", schema(format = "email"))]
pub email: Option<String>,
#[serde(skip)]
pub password: Option<String>,
pub relationships: Vec<Relationship>,
}
impl std::ops::Deref for ClientUser {
type Target = User;
fn deref(&self) -> &Self::Target {
&self.user
}
}
impl std::ops::DerefMut for ClientUser {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.user
}
}
impl ClientUser {
builder_methods! {
email: String => set_email + Some,
relationships: Vec<Relationship> => set_relationships,
}
}
#[derive(Copy, Clone, Debug, Default, Deserialize, PartialEq, Eq, Serialize)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub enum RelationshipType {
#[default]
Friend,
Blocked,
}
#[derive(Clone, Debug, Default, Serialize)]
#[cfg_attr(feature = "client", derive(Deserialize))]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub struct Relationship {
pub id: u64,
#[serde(rename = "type")]
pub kind: RelationshipType,
}