diff options
author | metamuffin <metamuffin@disroot.org> | 2024-01-30 13:58:52 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-01-30 13:58:52 +0100 |
commit | 0010717b6e86bb662fa04dab94968eee6fe8de64 (patch) | |
tree | 77c806b7eccdf5dd461f5b074d1693d9f9bd915d /common | |
parent | 88734e0f3ffdbce436fd0ceeabea70b96c60f1f8 (diff) | |
download | jellything-0010717b6e86bb662fa04dab94968eee6fe8de64.tar jellything-0010717b6e86bb662fa04dab94968eee6fe8de64.tar.bz2 jellything-0010717b6e86bb662fa04dab94968eee6fe8de64.tar.zst |
support native player in settings and jst
Diffstat (limited to 'common')
-rw-r--r-- | common/src/user.rs | 25 |
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>); |