From cb7b7e9c0f51027d6582df85377f8d0818b4b174 Mon Sep 17 00:00:00 2001 From: Valmo Trindade Date: Fri, 20 Sep 2024 17:02:32 -0300 Subject: [PATCH] added login info inside marker struct and created a marker payload struct to handle the sent json --- src/structs.rs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/structs.rs b/src/structs.rs index 477c55b..3c8b782 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -1,4 +1,4 @@ -use arma_rs::FromArma; +use arma_rs::{FromArma, FromArmaError}; use serde::{Deserialize, Serialize}; #[derive(Serialize)] @@ -13,10 +13,12 @@ pub struct Marker { pub hae: f64, pub api_address: String, pub api_auth_token: String, + pub api_auth_username: String, + pub api_auth_password: String, } impl FromArma for Marker { - fn from_arma(data: String) -> Result { + fn from_arma(data: String) -> Result { let ( uid, latitude, @@ -28,6 +30,8 @@ impl FromArma for Marker { hae, api_address, api_auth_token, + api_auth_username, + api_auth_password ) = <( String, f64, @@ -39,6 +43,8 @@ impl FromArma for Marker { f64, String, String, + String, + String )>::from_arma(data)?; Ok(Self { uid, @@ -51,11 +57,25 @@ impl FromArma for Marker { hae, api_address, api_auth_token, + api_auth_username, + api_auth_password }) } } #[derive(Debug, Serialize, Deserialize)] +pub struct MarkerPayload { + pub uid: String, + pub longitude: f64, + pub latitude: f64, + pub name: String, + pub r#type: String, + pub course: f64, + pub speed: f64, + pub hae: f64, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] pub struct LoginPayload { pub address: String, pub username: String, @@ -69,7 +89,7 @@ pub struct LoginInfo { } impl FromArma for LoginPayload { - fn from_arma(data: String) -> Result { + fn from_arma(data: String) -> Result { let (address, username, password) = <(String, String, String)>::from_arma(data)?; Ok(Self { address,