added location sender dll command

This commit is contained in:
Valmo Trindade
2024-10-21 02:14:46 -03:00
parent 059b749cab
commit acb3a49f85
3 changed files with 30 additions and 1 deletions

View File

@@ -9,6 +9,22 @@ pub struct LocationPayload {
pub bearing: f32,
}
pub trait IntoMessage {
fn into_message(self) -> String;
}
impl IntoMessage for String {
fn into_message(self) -> String {
self
}
}
impl IntoMessage for LocationPayload {
fn into_message(self) -> String {
serde_json::to_string(&self).unwrap() // Convert struct to JSON
}
}
impl FromArma for LocationPayload {
fn from_arma(data: String) -> Result<LocationPayload, FromArmaError> {
let (latitude, longitude, altitude, bearing) = <(f32, f32, f32, f32)>::from_arma(data)?;