aboutsummaryrefslogtreecommitdiff
path: root/common/src/user.rs
blob: 543162cd1eacfb4cc2be4c76a6953c041df2fafe (plain)
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
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)
    }
}