-
Notifications
You must be signed in to change notification settings - Fork 0
/
messages.rs
42 lines (38 loc) · 1.17 KB
/
messages.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
use crate::logging::Loggable;
use entities::{Book, BookPublic, User};
#[derive(strum_macros::AsRefStr, strum_macros::ToString)]
pub enum ActorGroups {
Input,
Book,
User,
}
resource_messaging::generate!(User, [(Create, Result<User, String>), (Login, User)]);
resource_messaging::generate!(
Book,
[
(BorrowByTitle, String),
(GetByTitle, Book),
(EndBorrowByTitle, ()),
(Create, Result<Book, String>),
(PublicList, Vec<BookPublic>),
]
);
impl Loggable for BookMsg {
fn to_log(&self) -> String {
match self {
BookMsg::GetByTitle(msg) => format!("{:#?}", msg.payload),
BookMsg::BorrowByTitle(msg) => format!("{:#?}", msg.payload),
BookMsg::EndBorrowByTitle(msg) => format!("{:#?}", msg.payload),
BookMsg::Create(msg) => format!("{:#?}", msg.payload),
BookMsg::PublicList(msg) => format!("{:#?}", msg.payload),
}
}
}
impl Loggable for UserMsg {
fn to_log(&self) -> String {
match self {
UserMsg::Create(msg) => format!("{:#?}", msg.payload),
UserMsg::Login(msg) => format!("{:#?}", msg.payload),
}
}
}