diff --git a/src/commands.rs b/src/commands.rs index ccedc95..4504d9f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,15 +1,17 @@ pub(crate) mod markers { use log::info; + use crate::structs::Marker; + pub fn get(placeholder: String) -> &'static str { info!("{}", placeholder); return "not implemented yet"; } - pub fn post(placeholder: Vec) -> &'static str { - for item in placeholder { - info!("Item: {}", item) + pub fn post(data: Vec) -> &'static str { + for item in data { + info!("{} - {}", item.uid, item.name) } return "not implemented yet"; diff --git a/src/lib.rs b/src/lib.rs index cb293d1..1f00069 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,6 @@ use arma_rs::{arma, Extension, Group}; use util::get_uuid; mod commands; -mod services; mod structs; mod tests; mod util; diff --git a/src/structs.rs b/src/structs.rs index 0ba2bd8..f4c5c79 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -2,23 +2,56 @@ use serde::Serialize; #[derive(Serialize)] pub struct Marker { - pub longitude: f64, - pub latitude: f64, - pub name: String, - pub uid: String, - pub r#type: Option, - pub course: Option, - pub azimuth: Option, - pub speed: Option, - pub battery: Option, - pub fov: Option, - pub ce: Option, - pub hae: Option, - pub le: Option, + pub longitude: f64, + pub latitude: f64, + pub name: String, + pub uid: String, + pub r#type: String, + pub course: i32, + pub speed: i32, + pub hae: i32, + pub api_address: String, + pub api_auth_token: String, } -pub struct MarkerPayload { - pub api_address: String, - pub api_auth_token: String, - pub markers: [Marker], -} \ No newline at end of file +use arma_rs::FromArma; + +impl FromArma for Marker { + fn from_arma(data: String) -> Result { + let ( + uid, + latitude, + longitude, + speed, + course, + r#type, + name, + hae, + api_address, + api_auth_token, + ) = <( + String, + f64, + f64, + i32, + i32, + String, + String, + i32, + String, + String, + )>::from_arma(data)?; + Ok(Self { + uid, + latitude, + longitude, + speed, + course, + r#type, + name, + hae, + api_address, + api_auth_token, + }) + } +} diff --git a/src/util.rs b/src/util.rs index 02a3dd3..6bad757 100644 --- a/src/util.rs +++ b/src/util.rs @@ -12,12 +12,4 @@ mod request { pub fn post(data: String) -> &'static str { return "not implemented yet"; } - - pub fn get(data: String) -> &'static str { - return "not implemented yet"; - } - - pub fn delete(data: String) -> &'static str { - return "not implemented yet"; - } }