1use super::*;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4pub enum Relation {
5 Tenant,
6 Site,
7 Brand,
8 Storefront,
9 Event,
10 Slot,
11 Folder,
12 Library,
13 Member,
14 Owner,
15 Admin,
16 Editor,
17 Viewer,
18 Support,
19 Merchandiser,
20 View,
21 Edit,
22 Publish,
23 Manage,
24 FeaturedEdit,
25 Checkout,
26 Refund,
27 Read,
28 ReadPublic,
29 Replace,
30 Delete,
31 Unpublish,
32 ManageStorage,
33 Book,
34 CheckIn,
35}
36
37impl Relation {
38 pub const fn as_str(self) -> &'static str {
39 match self {
40 Self::Tenant => "tenant",
41 Self::Site => "site",
42 Self::Brand => "brand",
43 Self::Storefront => "storefront",
44 Self::Event => "event",
45 Self::Slot => "slot",
46 Self::Folder => "folder",
47 Self::Library => "library",
48 Self::Member => "member",
49 Self::Owner => "owner",
50 Self::Admin => "admin",
51 Self::Editor => "editor",
52 Self::Viewer => "viewer",
53 Self::Support => "support",
54 Self::Merchandiser => "merchandiser",
55 Self::View => "view",
56 Self::Edit => "edit",
57 Self::Publish => "publish",
58 Self::Manage => "manage",
59 Self::FeaturedEdit => "featured_edit",
60 Self::Checkout => "checkout",
61 Self::Refund => "refund",
62 Self::Read => "read",
63 Self::ReadPublic => "read_public",
64 Self::Replace => "replace",
65 Self::Delete => "delete",
66 Self::Unpublish => "unpublish",
67 Self::ManageStorage => "manage_storage",
68 Self::Book => "book",
69 Self::CheckIn => "check_in",
70 }
71 }
72
73 pub fn from_str(value: &str) -> Option<Self> {
74 match value {
75 "tenant" => Some(Self::Tenant),
76 "site" => Some(Self::Site),
77 "brand" => Some(Self::Brand),
78 "storefront" => Some(Self::Storefront),
79 "event" => Some(Self::Event),
80 "slot" => Some(Self::Slot),
81 "folder" => Some(Self::Folder),
82 "library" => Some(Self::Library),
83 "member" => Some(Self::Member),
84 "owner" => Some(Self::Owner),
85 "admin" => Some(Self::Admin),
86 "editor" => Some(Self::Editor),
87 "viewer" => Some(Self::Viewer),
88 "support" => Some(Self::Support),
89 "merchandiser" => Some(Self::Merchandiser),
90 "view" => Some(Self::View),
91 "edit" => Some(Self::Edit),
92 "publish" => Some(Self::Publish),
93 "manage" => Some(Self::Manage),
94 "featured_edit" => Some(Self::FeaturedEdit),
95 "checkout" => Some(Self::Checkout),
96 "refund" => Some(Self::Refund),
97 "read" => Some(Self::Read),
98 "read_public" => Some(Self::ReadPublic),
99 "replace" => Some(Self::Replace),
100 "delete" => Some(Self::Delete),
101 "unpublish" => Some(Self::Unpublish),
102 "manage_storage" => Some(Self::ManageStorage),
103 "book" => Some(Self::Book),
104 "check_in" => Some(Self::CheckIn),
105 _ => None,
106 }
107 }
108}
109
110impl fmt::Display for Relation {
111 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
112 f.write_str(self.as_str())
113 }
114}