mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 20:24:34 +00:00
added login info inside marker struct and created a marker payload struct to handle the sent json
This commit is contained in:
@@ -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<Self, String> {
|
||||
fn from_arma(data: String) -> Result<Marker, FromArmaError> {
|
||||
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<Self, String> {
|
||||
fn from_arma(data: String) -> Result<LoginPayload, FromArmaError> {
|
||||
let (address, username, password) = <(String, String, String)>::from_arma(data)?;
|
||||
Ok(Self {
|
||||
address,
|
||||
|
||||
Reference in New Issue
Block a user