melvin_ob/http_handler/http_request/
control_put.rs

1use super::control_satellite::ControlSatelliteResponse;
2use super::request_common::{HTTPRequestMethod, HTTPRequestType, JSONBodyHTTPRequestType};
3
4/// Request type for the /control endpoint.
5#[derive(serde::Serialize, Debug)]
6pub(crate) struct ControlSatelliteRequest {
7    /// The desired velocity in x-direction.
8    pub(crate) vel_x: f64,
9    /// The desired velocity in y-direction.
10    pub(crate) vel_y: f64,
11    /// The desired `CameraAngle` encoded as a `str`.
12    pub(crate) camera_angle: &'static str,
13    /// The desired `FlightState` encoded as a `str`.
14    pub(crate) state: &'static str,
15}
16
17impl JSONBodyHTTPRequestType for ControlSatelliteRequest {
18    /// The type of the json body.
19    type Body = ControlSatelliteRequest;
20    /// Returns the serializable object.
21    fn body(&self) -> &Self::Body { self }
22}
23
24impl HTTPRequestType for ControlSatelliteRequest {
25    /// Type of the expected response.
26    type Response = ControlSatelliteResponse;
27    /// `str` object representing the specific endpoint.
28    fn endpoint(&self) -> &'static str { "/control" }
29    /// The corresponding HTTP Request Method.
30    fn request_method(&self) -> HTTPRequestMethod { HTTPRequestMethod::Put }
31}