aboutsummaryrefslogtreecommitdiff
path: root/common/src/user.rs
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/user.rs')
-rw-r--r--common/src/user.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/common/src/user.rs b/common/src/user.rs
new file mode 100644
index 0000000..543162c
--- /dev/null
+++ b/common/src/user.rs
@@ -0,0 +1,30 @@
+use serde::{Deserialize, Serialize};
+use std::collections::HashMap;
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct User {
+ pub name: String,
+ pub display_name: String,
+ pub password: Vec<u8>,
+ pub admin: bool,
+ pub permissions: PermissionSet,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Default)]
+pub struct PermissionSet(pub HashMap<UserPermission, bool>);
+
+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
+#[serde(rename_all = "snake_case")]
+pub enum UserPermission {
+ OriginalStream,
+ Transcode,
+ ManageUsers,
+ GenerateInvite,
+}
+
+impl UserPermission {
+ pub fn default_value(&self) -> bool {
+ use UserPermission::*;
+ matches!(self, Transcode)
+ }
+}