2021-11-07 21:23:18 +00:00
|
|
|
pub mod add_item_params;
|
2021-10-03 20:03:32 +00:00
|
|
|
pub mod add_location_params;
|
2021-10-31 17:00:07 +00:00
|
|
|
pub mod add_token_params;
|
2021-12-18 03:03:15 +00:00
|
|
|
pub mod delete_params;
|
2021-12-19 21:06:56 +00:00
|
|
|
pub mod edit_params;
|
2021-10-03 20:03:32 +00:00
|
|
|
pub mod find_params;
|
2021-12-19 22:16:22 +00:00
|
|
|
pub mod info_params;
|
2021-12-31 03:48:33 +00:00
|
|
|
pub mod item_command_params;
|
2021-12-18 18:13:18 +00:00
|
|
|
pub mod link_params;
|
2021-10-03 20:03:32 +00:00
|
|
|
pub mod register_params;
|
2021-11-07 21:23:18 +00:00
|
|
|
pub mod selling_params;
|
2021-12-08 03:33:25 +00:00
|
|
|
pub mod set_portal_params;
|
2021-10-03 20:03:32 +00:00
|
|
|
|
2021-12-18 03:03:15 +00:00
|
|
|
use crate::models::player::UserID;
|
2021-10-24 19:21:30 +00:00
|
|
|
use serde::de::DeserializeOwned;
|
2021-12-18 03:03:15 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2021-10-24 19:20:15 +00:00
|
|
|
use std::fmt::Debug;
|
2021-10-03 20:03:32 +00:00
|
|
|
|
2021-12-18 03:03:15 +00:00
|
|
|
pub trait GeoffreyParam: Serialize + DeserializeOwned + Debug + Clone + Send + Sync {}
|
2021-10-03 20:03:32 +00:00
|
|
|
|
2022-02-06 22:32:33 +00:00
|
|
|
pub trait GeoffreyRequest<T> {
|
|
|
|
fn get_token(&self) -> String;
|
|
|
|
fn get_params(&self) -> &T;
|
|
|
|
}
|
|
|
|
|
2021-12-18 03:03:15 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
|
|
pub struct CommandRequest<T> {
|
|
|
|
pub token: String,
|
|
|
|
pub user_id: Option<UserID>,
|
|
|
|
pub params: T,
|
2021-10-24 19:21:30 +00:00
|
|
|
}
|
2022-01-08 19:35:55 +00:00
|
|
|
|
2022-02-06 22:32:33 +00:00
|
|
|
impl<T> GeoffreyRequest<T> for CommandRequest<T> {
|
|
|
|
fn get_token(&self) -> String {
|
|
|
|
self.token.clone()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_params(&self) -> &T {
|
|
|
|
&self.params
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
|
|
pub struct ModelRequest<T> {
|
|
|
|
pub token: String,
|
|
|
|
pub params: T,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> GeoffreyRequest<T> for ModelRequest<T> {
|
|
|
|
fn get_token(&self) -> String {
|
|
|
|
self.token.clone()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_params(&self) -> &T {
|
|
|
|
&self.params
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-08 19:35:55 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
|
|
pub struct EmptyRequest {}
|
|
|
|
|
|
|
|
impl GeoffreyParam for EmptyRequest {}
|