melvin_ob/http_handler/http_request/
configure_simulation_put.rs

1use super::configure_simulation;
2use super::request_common::{
3    HTTPRequestMethod, HTTPRequestType, NoBodyHTTPRequestType, bool_to_string,
4};
5use std::collections::HashMap;
6
7/// Request type for the /simulation endpoint.
8#[derive(Debug)]
9#[cfg(debug_assertions)]
10pub(crate) struct ConfigureSimulationRequest {
11    /// Switch to toggle network simulation on and off.
12    pub(crate) is_network_simulation: bool,
13    /// The desired timestep multiplier for the simulation backend.
14    pub(crate) user_speed_multiplier: u32,
15}
16
17impl NoBodyHTTPRequestType for ConfigureSimulationRequest {}
18
19impl HTTPRequestType for ConfigureSimulationRequest {
20    /// Type of the expected response.
21    type Response = configure_simulation::ConfigureSimulationResponse;
22    /// `str` object representing the specific endpoint.
23    fn endpoint(&self) -> &'static str { "/simulation" }
24    /// The corresponding HTTP Request Method.
25    fn request_method(&self) -> HTTPRequestMethod { HTTPRequestMethod::Put }
26    /// `HashMap` containing the query param key value pairs.
27    fn query_params(&self) -> HashMap<&str, String> {
28        let mut query = HashMap::new();
29        query.insert(
30            "is_network_simulation",
31            bool_to_string(self.is_network_simulation).to_string(),
32        );
33        query.insert(
34            "user_speed_multiplier",
35            self.user_speed_multiplier.to_string(),
36        );
37        query
38    }
39}