mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 15:43:29 +00:00
formatted some rust files for linting porpuses
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
use uuid::Uuid;
|
|
||||||
use chrono::{Duration, SecondsFormat, Utc};
|
use chrono::{Duration, SecondsFormat, Utc};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
pub struct CursorOverTime {
|
pub struct CursorOverTime {
|
||||||
pub uuid: Option<String>,
|
pub uuid: Option<String>,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use arma_rs::{FromArma, FromArmaError};
|
|
||||||
use super::cot::CursorOverTime;
|
use super::cot::CursorOverTime;
|
||||||
|
use arma_rs::{FromArma, FromArmaError};
|
||||||
|
|
||||||
pub struct DigitalPointerPayload {
|
pub struct DigitalPointerPayload {
|
||||||
pub link_uid: String,
|
pub link_uid: String,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use arma_rs::{FromArma, FromArmaError};
|
|
||||||
use super::cot::CursorOverTime;
|
use super::cot::CursorOverTime;
|
||||||
|
use arma_rs::{FromArma, FromArmaError};
|
||||||
|
|
||||||
pub struct EudCoTPayload {
|
pub struct EudCoTPayload {
|
||||||
pub uuid: String,
|
pub uuid: String,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use arma_rs::{FromArma, FromArmaError};
|
|
||||||
use super::cot::CursorOverTime;
|
use super::cot::CursorOverTime;
|
||||||
|
use arma_rs::{FromArma, FromArmaError};
|
||||||
|
|
||||||
pub struct ExternalPositionPayload {
|
pub struct ExternalPositionPayload {
|
||||||
pub uuid: String,
|
pub uuid: String,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use arma_rs::{FromArma, FromArmaError};
|
use arma_rs::{FromArma, FromArmaError};
|
||||||
use chrono::{Utc, Duration, SecondsFormat};
|
use chrono::{Duration, SecondsFormat, Utc};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
pub struct MessagePayload {
|
pub struct MessagePayload {
|
||||||
@@ -14,8 +14,7 @@ pub struct MessagePayload {
|
|||||||
|
|
||||||
impl FromArma for MessagePayload {
|
impl FromArma for MessagePayload {
|
||||||
fn from_arma(data: String) -> Result<Self, FromArmaError> {
|
fn from_arma(data: String) -> Result<Self, FromArmaError> {
|
||||||
let (sender_callsign, chatroom, message_text,
|
let (sender_callsign, chatroom, message_text, point_lat, point_lon, point_hae, sender_uid) =
|
||||||
point_lat, point_lon, point_hae, sender_uid) =
|
|
||||||
<(String, String, String, f64, f64, f32, String)>::from_arma(data)?;
|
<(String, String, String, f64, f64, f32, String)>::from_arma(data)?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
@@ -55,8 +54,8 @@ impl MessageCot {
|
|||||||
|
|
||||||
pub fn to_xml(&self) -> String {
|
pub fn to_xml(&self) -> String {
|
||||||
let created_time = Utc::now().to_rfc3339_opts(SecondsFormat::Millis, true);
|
let created_time = Utc::now().to_rfc3339_opts(SecondsFormat::Millis, true);
|
||||||
let stale_time = (Utc::now() + Duration::days(1))
|
let stale_time =
|
||||||
.to_rfc3339_opts(SecondsFormat::Millis, true);
|
(Utc::now() + Duration::days(1)).to_rfc3339_opts(SecondsFormat::Millis, true);
|
||||||
|
|
||||||
// MESSAGE ID (random UUID)
|
// MESSAGE ID (random UUID)
|
||||||
let message_uuid = Uuid::new_v4().to_string();
|
let message_uuid = Uuid::new_v4().to_string();
|
||||||
@@ -98,10 +97,7 @@ impl MessageCot {
|
|||||||
format!(
|
format!(
|
||||||
"<__chat parent=\"RootContactGroup\" groupOwner=\"false\" \
|
"<__chat parent=\"RootContactGroup\" groupOwner=\"false\" \
|
||||||
messageId=\"{}\" chatroom=\"{}\" id=\"{}\" senderCallsign=\"{}\">",
|
messageId=\"{}\" chatroom=\"{}\" id=\"{}\" senderCallsign=\"{}\">",
|
||||||
message_uuid,
|
message_uuid, self.chatroom, self.chatroom, self.sender_callsign,
|
||||||
self.chatroom,
|
|
||||||
self.chatroom,
|
|
||||||
self.sender_callsign,
|
|
||||||
)
|
)
|
||||||
.as_str(),
|
.as_str(),
|
||||||
);
|
);
|
||||||
@@ -109,9 +105,7 @@ impl MessageCot {
|
|||||||
xml.push_str(
|
xml.push_str(
|
||||||
format!(
|
format!(
|
||||||
"<chatgrp uid0=\"{}\" uid1=\"{}\" id=\"{}\" />",
|
"<chatgrp uid0=\"{}\" uid1=\"{}\" id=\"{}\" />",
|
||||||
self.sender_uid,
|
self.sender_uid, self.chatroom, self.chatroom
|
||||||
self.chatroom,
|
|
||||||
self.chatroom
|
|
||||||
)
|
)
|
||||||
.as_str(),
|
.as_str(),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
pub mod draws;
|
|
||||||
pub mod cot;
|
pub mod cot;
|
||||||
pub mod digital_pointer;
|
pub mod digital_pointer;
|
||||||
|
pub mod draws;
|
||||||
pub mod eud;
|
pub mod eud;
|
||||||
pub mod gps;
|
pub mod gps;
|
||||||
pub mod message;
|
pub mod message;
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ pub struct LogPayload {
|
|||||||
impl FromArma for LogPayload {
|
impl FromArma for LogPayload {
|
||||||
fn from_arma(data: String) -> Result<LogPayload, FromArmaError> {
|
fn from_arma(data: String) -> Result<LogPayload, FromArmaError> {
|
||||||
let (status, message) = <(String, String)>::from_arma(data)?;
|
let (status, message) = <(String, String)>::from_arma(data)?;
|
||||||
Ok(Self {
|
Ok(Self { status, message })
|
||||||
status,
|
|
||||||
message
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,21 +9,30 @@ pub fn send_eud_cot(ctx: Context, cursor_over_time: cot::eud::EudCoTPayload) ->
|
|||||||
"Sending End User Device Cursor Over Time to TCP server"
|
"Sending End User Device Cursor Over Time to TCP server"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_marker_cot(ctx: Context, cursor_over_time: cot::nato::MarkerCoTPayload) -> &'static str {
|
pub fn send_marker_cot(
|
||||||
|
ctx: Context,
|
||||||
|
cursor_over_time: cot::nato::MarkerCoTPayload,
|
||||||
|
) -> &'static str {
|
||||||
let payload = cursor_over_time.to_cot().convert_to_xml();
|
let payload = cursor_over_time.to_cot().convert_to_xml();
|
||||||
send_payload(ctx, payload);
|
send_payload(ctx, payload);
|
||||||
|
|
||||||
"Sending Marker Cursor Over Time to TCP server"
|
"Sending Marker Cursor Over Time to TCP server"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_digital_pointer_cot(ctx: Context, cursor_over_time: cot::digital_pointer::DigitalPointerPayload) -> &'static str {
|
pub fn send_digital_pointer_cot(
|
||||||
|
ctx: Context,
|
||||||
|
cursor_over_time: cot::digital_pointer::DigitalPointerPayload,
|
||||||
|
) -> &'static str {
|
||||||
let payload = cursor_over_time.to_cot().convert_to_xml();
|
let payload = cursor_over_time.to_cot().convert_to_xml();
|
||||||
send_payload(ctx, payload);
|
send_payload(ctx, payload);
|
||||||
|
|
||||||
"Sending Digital Pointer Cursor Over Time to TCP server"
|
"Sending Digital Pointer Cursor Over Time to TCP server"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_message_cot(ctx: Context, message_payload: cot::message::MessagePayload) -> &'static str {
|
pub fn send_message_cot(
|
||||||
|
ctx: Context,
|
||||||
|
message_payload: cot::message::MessagePayload,
|
||||||
|
) -> &'static str {
|
||||||
let message_cot = cot::message::MessageCot::from_payload(message_payload);
|
let message_cot = cot::message::MessageCot::from_payload(message_payload);
|
||||||
let payload = message_cot.to_xml();
|
let payload = message_cot.to_xml();
|
||||||
send_payload(ctx, payload);
|
send_payload(ctx, payload);
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ use arma_rs::Context;
|
|||||||
|
|
||||||
use crate::{cot, tcp::send_payload};
|
use crate::{cot, tcp::send_payload};
|
||||||
|
|
||||||
pub fn send_circle_cot(ctx: Context, circle_payload: cot::draws::circle::CircleCoTPayload) -> &'static str {
|
pub fn send_circle_cot(
|
||||||
|
ctx: Context,
|
||||||
|
circle_payload: cot::draws::circle::CircleCoTPayload,
|
||||||
|
) -> &'static str {
|
||||||
let shape_circle_cot = circle_payload.to_cot();
|
let shape_circle_cot = circle_payload.to_cot();
|
||||||
let now = chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Millis, true);
|
let now = chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Millis, true);
|
||||||
let stale = (chrono::Utc::now() + chrono::Duration::days(1))
|
let stale = (chrono::Utc::now() + chrono::Duration::days(1))
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::init;
|
use crate::init;
|
||||||
use uuid::Uuid;
|
|
||||||
use std::vec;
|
use std::vec;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn uuid_output_is_uuid4_identifier() {
|
fn uuid_output_is_uuid4_identifier() {
|
||||||
@@ -17,9 +17,9 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn uuid_output_throws_if_passed_args() {
|
fn uuid_output_throws_if_passed_args() {
|
||||||
let extension = init().testing();
|
let extension = init().testing();
|
||||||
let args: Vec<String> = vec![1.to_string(),2.to_string()];
|
let args: Vec<String> = vec![1.to_string(), 2.to_string()];
|
||||||
let (output, _) = extension.call("uuid", Some(args));
|
let (output, _) = extension.call("uuid", Some(args));
|
||||||
|
|
||||||
assert_eq!(output,"")
|
assert_eq!(output, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,10 @@ pub fn send_payload(ctx: Context, payload: String) -> &'static str {
|
|||||||
"Sending payload to UDP server"
|
"Sending payload to UDP server"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_gps_cot(ctx: Context, cursor_over_time: cot::gps::ExternalPositionPayload) -> &'static str {
|
pub fn send_gps_cot(
|
||||||
|
ctx: Context,
|
||||||
|
cursor_over_time: cot::gps::ExternalPositionPayload,
|
||||||
|
) -> &'static str {
|
||||||
let payload = cursor_over_time.to_cot().convert_to_xml();
|
let payload = cursor_over_time.to_cot().convert_to_xml();
|
||||||
send_payload(ctx, payload);
|
send_payload(ctx, payload);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
pub mod uuid;
|
|
||||||
pub mod address;
|
pub mod address;
|
||||||
pub mod log;
|
pub mod log;
|
||||||
|
pub mod uuid;
|
||||||
|
|||||||
@@ -16,7 +16,13 @@ lazy_static! {
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||||
|
|
||||||
fn build_rtsp_url(address: &str, port: &str, stream_path: &str, username: &str, password: &str) -> String {
|
fn build_rtsp_url(
|
||||||
|
address: &str,
|
||||||
|
port: &str,
|
||||||
|
stream_path: &str,
|
||||||
|
username: &str,
|
||||||
|
password: &str,
|
||||||
|
) -> String {
|
||||||
if username.is_empty() || password.is_empty() {
|
if username.is_empty() || password.is_empty() {
|
||||||
format!("rtsp://{}:{}/{}", address, port, stream_path)
|
format!("rtsp://{}:{}/{}", address, port, stream_path)
|
||||||
} else {
|
} else {
|
||||||
@@ -28,20 +34,22 @@ fn build_rtsp_url(address: &str, port: &str, stream_path: &str, username: &str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||||
fn spawn_ffmpeg(
|
fn spawn_ffmpeg(rtsp_url: String, stop_rx: Receiver<()>, status_tx: Sender<Result<(), String>>) {
|
||||||
rtsp_url: String,
|
|
||||||
stop_rx: Receiver<()>,
|
|
||||||
status_tx: Sender<Result<(), String>>,
|
|
||||||
) {
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let mut cmd = Command::new("ffmpeg");
|
let mut cmd = Command::new("ffmpeg");
|
||||||
cmd.args(&[
|
cmd.args(&[
|
||||||
"-f","x11grab",
|
"-f",
|
||||||
"-framerate","30",
|
"x11grab",
|
||||||
"-video_size","1920x1080",
|
"-framerate",
|
||||||
"-i" ,":0",
|
"30",
|
||||||
"-f","rtsp",
|
"-video_size",
|
||||||
"-rtsp_transport","tcp",
|
"1920x1080",
|
||||||
|
"-i",
|
||||||
|
":0",
|
||||||
|
"-f",
|
||||||
|
"rtsp",
|
||||||
|
"-rtsp_transport",
|
||||||
|
"tcp",
|
||||||
&rtsp_url,
|
&rtsp_url,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user