Geoffrey-rs/geoffrey_models/src/models/parameters/add_location_params.rs

52 lines
1.1 KiB
Rust

use crate::models::locations::LocationType;
use crate::models::parameters::CommandRequest;
use crate::models::player::UserID;
use crate::models::{Position, Tunnel};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct AddLocationParams {
pub token: String,
pub user_id: UserID,
pub name: String,
pub position: Position,
pub loc_type: LocationType,
pub tunnel: Option<Tunnel>,
}
impl AddLocationParams {
pub fn new(
name: String,
position: Position,
loc_type: LocationType,
tunnel: Option<Tunnel>,
) -> Self {
Self {
token: Default::default(),
user_id: Default::default(),
name,
position,
loc_type,
tunnel,
}
}
}
impl CommandRequest for AddLocationParams {
fn token(&self) -> String {
self.token.clone()
}
fn user_id(&self) -> Option<UserID> {
Some(self.user_id.clone())
}
fn set_user_id(&mut self, user_id: UserID) {
self.user_id = user_id;
}
fn set_token(&mut self, token: String) {
self.token = token;
}
}