-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.rs
86 lines (82 loc) · 2.06 KB
/
data.rs
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
use serde::{Deserialize, Serialize};
pub mod access_mask {
// 0x001 => Borrow books
// 0x011 => Manage books + 0x01
// 0x111 => Super user
pub const USER: i32 = 0x001;
pub const LIBRARIAN: i32 = 0x011;
pub const ADMIN: i32 = 0x111;
}
type BookBorrowLength = i64;
type BookTitle = String;
type UserEmail = String;
#[derive(Serialize, Deserialize, Debug)]
pub struct Book {
pub title: String,
pub borrow_id: Option<UserEmail>,
pub borrow_until: Option<BookBorrowLength>
}
#[derive(Serialize, Deserialize, Debug)]
pub struct BookPublic {
pub title: String,
pub borrow_until: Option<BookBorrowLength>,
}
#[derive(Deserialize, Debug)]
pub struct BookGetByTitlePayload {
pub title: BookTitle,
}
#[derive(Deserialize, Debug)]
pub struct BookBorrowByTitleRequestBody {
pub borrow_length: BookBorrowLength,
pub borrow_id: String,
}
#[derive(Serialize, Debug)]
pub struct BookEndBorrowByTitlePayload {
pub title: BookTitle,
pub access_token: String,
}
#[derive(Deserialize, Debug)]
pub struct BookCreatePayloadRequestBody {
pub title: BookTitle,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct BookCreatePayload {
pub title: BookTitle,
pub access_token: String,
}
#[derive(Serialize, Debug)]
pub struct BookBorrowByTitlePayload {
pub title: BookTitle,
pub borrow_id: String,
pub borrow_length: BookBorrowLength,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct BookPublicListPayload {
pub query: Option<String>,
}
#[derive(Deserialize)]
#[allow(non_snake_case)]
pub struct BookOkResponse {
pub Ok: Book,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct User {
pub email: String,
pub access_mask: i32,
pub access_token: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct UserCreatePayload {
pub email: String,
pub access_mask: i32,
pub requester_access_token: Option<String>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct UserLoginPayload {
pub email: String,
}
#[derive(Deserialize)]
#[allow(non_snake_case)]
pub struct UserOkResponse {
pub Ok: User,
}