tweechat_datatypes/
lib.rs1#![deny(clippy::cargo)]
2use serde::{Deserialize, Serialize};
3
4#[derive(Deserialize, Serialize, Clone, Debug)]
6pub struct User {
7 pub name: String,
8 pub id: u128,
9}
10
11#[derive(Deserialize, Serialize, Clone, Debug)]
13pub struct ApiError {
14 pub error: String,
15}
16
17#[derive(Deserialize, Serialize, Clone, Debug)]
19pub struct LoginResponse {
20 pub token: String,
21 pub needs_totp: bool,
22}
23
24#[derive(Deserialize, Serialize, Clone, Debug)]
26pub struct TotpRequest {
27 pub code: String,
28}
29
30#[derive(Deserialize, Serialize, Clone, Debug)]
31pub struct MessageCreate {
32 pub contents: String,
33 pub author: User,
34 pub created: u64,
35}
36
37#[derive(Serialize, Deserialize)]
38pub struct UserCreate {
39 pub email: String,
40 pub name: String,
41 pub password: String,
42 pub pubkey: String,
43 pub privkey: String,
44 pub security_level: UserSecurityLevel,
45}
46
47#[derive(Serialize, Deserialize)]
48pub enum UserSecurityLevel {
49 Max,
50 Reasonable,
51 Low,
52}
53
54impl ToString for UserSecurityLevel {
55 fn to_string(&self) -> String {
56 match self {
57 Self::Max => "Max".to_string(),
58 Self::Reasonable => "Reasonable".to_string(),
59 Self::Low => "Low".to_string(),
60 }
61 }
62}