#[allow(dead_code)] #[derive(Debug)] pub struct UserToken { pub uuid: String, pub token: String, pub refresh_token: String, } pub struct UserInfo { pub payload: libfj::robocraft::TokenPayload, pub extra: ExtraUserInfo, } pub enum ExtraUserInfo { Steam { id: u64, }, Username { password: String, }, Email { password: String, } } pub enum UserId { SteamId(u64), Email(String), Username(String), } pub struct UserLoginInfo { pub response: libfj::robocraft::AuthenticationResponseInfo, pub is_new: bool, } pub struct RegistrationInfo { pub display_name: String, pub password: String, pub email: Option, pub steam_id: Option, } #[async_trait::async_trait] pub trait UserProvider { async fn authenticate(&self, user: UserToken, ext: std::collections::HashMap>) -> Result + Send + Sync>, String>; } #[async_trait::async_trait] pub trait UserAuthenticator { async fn login(&self, info: UserInfo) -> Result; async fn user_exists(&self, user: UserId) -> Result; async fn register(&self, info: RegistrationInfo) -> Result; } #[async_trait::async_trait] pub trait User: ChatUser { fn ext(&self, ty: std::any::TypeId) -> Option<&'_ (dyn std::any::Any + Send + Sync + 'static)>; fn token(&self) -> &'_ super::UserToken; fn is_mod(&self) -> bool; fn is_admin(&self) -> bool; fn is_dev(&self) -> bool; async fn unlocked_parts(&self) -> Vec; async fn selected_garage(&self) -> (String, u32); async fn select_garage(&self, slot: i32) -> Result<(), i16>; async fn all_slots(&self) -> UserSlots; async fn slot_by_id(&self, id: i32) -> Result, i16>; async fn save_slot(&self, vehicle: VehicleData) -> Result<(), i16>; async fn save_slot_order(&self, slots: Vec) -> Result<(), i16>; async fn new_slot(&self, reset_slot: Option) -> Result, i16>; async fn upgrade_slot(&self, increments: i32) -> Result, i16>; fn signup_date(&self) -> i64; async fn singleplayer_robots(&self) -> Result, i16>; async fn prepare_factory_upload(&self, vehicle: VehicleUploadData) -> Result; async fn last_seen(&self) -> Result; async fn get_avatar_info(&self) -> Result, i16>; async fn set_avatar_info(&self, info: AvatarInfo) -> Result<(), i16>; } pub struct UserSlots { pub slot_info: polariton::operation::Typed, pub slot_order: polariton::operation::Typed, } pub struct UserSlotData { pub data: polariton::operation::Typed, pub colour_data: polariton::operation::Typed, pub cube_count: polariton::operation::Typed, pub weapon_order: polariton::operation::Typed, pub movement_categories: polariton::operation::Typed, pub control_type: polariton::operation::Typed, pub control_options: polariton::operation::Typed, pub mastery_level: polariton::operation::Typed, pub robot_rank: polariton::operation::Typed, pub cpu: polariton::operation::Typed, pub cosmetic_cpu: polariton::operation::Typed, pub uuid: polariton::operation::Typed, } pub struct NewSlotData { pub name: polariton::operation::Typed, pub uuid_0: polariton::operation::Typed, pub uuid_1: polariton::operation::Typed, pub slot: polariton::operation::Typed, pub bay_cpu: polariton::operation::Typed, pub mastery_level: polariton::operation::Typed, pub slot_i: i32, } pub struct VehicleData { pub name: Option, pub slot: i32, pub robot_data: Vec, pub colour_data: Vec, pub weapon_order: Vec, pub crf_id: Option, } pub struct VehicleUploadData { pub version: String, pub slot: i32, pub name: String, pub description: String, pub thumbnail: Vec, } pub struct GetAvatarInfo { pub avatar_id: polariton::operation::Typed, pub use_custom: polariton::operation::Typed, } pub struct AvatarInfo { pub avatar_id: i32, pub use_custom: bool, } #[async_trait::async_trait] pub trait ChatUser { async fn subscribed_channels(&self) -> Result, i16>; async fn subscribed_channels_strings(&self) -> Result, i16>; async fn add_subscribed_channel(&self, channel: String, channel_ty: crate::data::channel::ChatChannelType) -> Result, i16>; async fn remove_subscribed_channel(&self, channel: String, channel_ty: crate::data::channel::ChatChannelType) -> Result<(), i16>; }