-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresource_action.rs
More file actions
37 lines (34 loc) · 902 Bytes
/
resource_action.rs
File metadata and controls
37 lines (34 loc) · 902 Bytes
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
use std::fmt;
/// Actions that can be taken in the database
#[derive(Debug)]
pub enum ResourceAction {
Create,
ReadPrivate,
Update,
Delete,
OpenRegistration,
Register,
InitVoting,
Vote,
CloseVoting,
}
impl ResourceAction {
pub fn get_name(&self) -> &'static str {
match self {
ResourceAction::Create => "Create",
ResourceAction::ReadPrivate => "Read",
ResourceAction::Update => "Update",
ResourceAction::Delete => "Delete",
ResourceAction::OpenRegistration => "Open Registration for",
ResourceAction::Register => "Register for",
ResourceAction::InitVoting => "Initialize voting for",
ResourceAction::Vote => "Vote in",
ResourceAction::CloseVoting => "Close voting for",
}
}
}
impl fmt::Display for ResourceAction {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.get_name())
}
}