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.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/common/src/user.rs b/common/src/user.rs
index 085f9db..4b39673 100644
--- a/common/src/user.rs
+++ b/common/src/user.rs
@@ -13,13 +13,16 @@ use std::{
fmt::Display,
};
-#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode)]
+#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, Default)]
pub struct User {
pub name: String,
pub display_name: String,
pub password: Vec<u8>,
pub admin: bool,
+ #[serde(default)]
pub theme: Theme,
+ #[serde(default)]
+ pub player_preference: PlayerKind,
pub permissions: PermissionSet,
}
@@ -45,15 +48,26 @@ pub struct CreateSessionParams {
pub drop_permissions: Option<HashSet<UserPermission>>,
}
-#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Encode, Decode)]
+#[derive(Debug, Clone, Copy, Serialize, Default, Deserialize, PartialEq, Encode, Decode)]
#[cfg_attr(feature = "rocket", derive(FromFormField, UriDisplayQuery))]
#[serde(rename_all = "snake_case")]
pub enum Theme {
+ #[default]
Dark,
Light,
Purple,
}
+#[derive(Debug, Clone, Copy, Serialize, Default, Deserialize, PartialEq, Encode, Decode)]
+#[cfg_attr(feature = "rocket", derive(FromFormField, UriDisplayQuery))]
+#[serde(rename_all = "snake_case")]
+pub enum PlayerKind {
+ #[default]
+ Browser,
+ Native,
+ NativeFullscreen,
+}
+
impl Theme {
pub const LIST: &'static [(Theme, &'static str)] = &[
(Theme::Dark, "Dark"),
@@ -61,6 +75,13 @@ impl Theme {
(Theme::Purple, "Purple"),
];
}
+impl PlayerKind {
+ pub const LIST: &'static [(PlayerKind, &'static str)] = &[
+ (PlayerKind::Browser, "In-Browser"),
+ (PlayerKind::Native, "Native"),
+ (PlayerKind::NativeFullscreen, "Native (Fullscreen)"),
+ ];
+}
#[derive(Debug, Clone, Serialize, Deserialize, Default, Encode, Decode)]
pub struct PermissionSet(pub HashMap<UserPermission, bool>);