mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 14:23:28 +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 uuid::Uuid;
|
||||
|
||||
pub struct CursorOverTime {
|
||||
pub uuid: Option<String>,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use arma_rs::{FromArma, FromArmaError};
|
||||
use super::cot::CursorOverTime;
|
||||
use arma_rs::{FromArma, FromArmaError};
|
||||
|
||||
pub struct DigitalPointerPayload {
|
||||
pub link_uid: String,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use arma_rs::{FromArma, FromArmaError};
|
||||
use super::cot::CursorOverTime;
|
||||
use arma_rs::{FromArma, FromArmaError};
|
||||
|
||||
pub struct EudCoTPayload {
|
||||
pub uuid: String,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use arma_rs::{FromArma, FromArmaError};
|
||||
use super::cot::CursorOverTime;
|
||||
use arma_rs::{FromArma, FromArmaError};
|
||||
|
||||
pub struct ExternalPositionPayload {
|
||||
pub uuid: String,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use arma_rs::{FromArma, FromArmaError};
|
||||
use chrono::{Utc, Duration, SecondsFormat};
|
||||
use chrono::{Duration, SecondsFormat, Utc};
|
||||
use uuid::Uuid;
|
||||
|
||||
pub struct MessagePayload {
|
||||
@@ -14,8 +14,7 @@ pub struct MessagePayload {
|
||||
|
||||
impl FromArma for MessagePayload {
|
||||
fn from_arma(data: String) -> Result<Self, FromArmaError> {
|
||||
let (sender_callsign, chatroom, message_text,
|
||||
point_lat, point_lon, point_hae, sender_uid) =
|
||||
let (sender_callsign, chatroom, message_text, point_lat, point_lon, point_hae, sender_uid) =
|
||||
<(String, String, String, f64, f64, f32, String)>::from_arma(data)?;
|
||||
|
||||
Ok(Self {
|
||||
@@ -55,8 +54,8 @@ impl MessageCot {
|
||||
|
||||
pub fn to_xml(&self) -> String {
|
||||
let created_time = Utc::now().to_rfc3339_opts(SecondsFormat::Millis, true);
|
||||
let stale_time = (Utc::now() + Duration::days(1))
|
||||
.to_rfc3339_opts(SecondsFormat::Millis, true);
|
||||
let stale_time =
|
||||
(Utc::now() + Duration::days(1)).to_rfc3339_opts(SecondsFormat::Millis, true);
|
||||
|
||||
// MESSAGE ID (random UUID)
|
||||
let message_uuid = Uuid::new_v4().to_string();
|
||||
@@ -98,10 +97,7 @@ impl MessageCot {
|
||||
format!(
|
||||
"<__chat parent=\"RootContactGroup\" groupOwner=\"false\" \
|
||||
messageId=\"{}\" chatroom=\"{}\" id=\"{}\" senderCallsign=\"{}\">",
|
||||
message_uuid,
|
||||
self.chatroom,
|
||||
self.chatroom,
|
||||
self.sender_callsign,
|
||||
message_uuid, self.chatroom, self.chatroom, self.sender_callsign,
|
||||
)
|
||||
.as_str(),
|
||||
);
|
||||
@@ -109,9 +105,7 @@ impl MessageCot {
|
||||
xml.push_str(
|
||||
format!(
|
||||
"<chatgrp uid0=\"{}\" uid1=\"{}\" id=\"{}\" />",
|
||||
self.sender_uid,
|
||||
self.chatroom,
|
||||
self.chatroom
|
||||
self.sender_uid, self.chatroom, self.chatroom
|
||||
)
|
||||
.as_str(),
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
pub mod draws;
|
||||
pub mod cot;
|
||||
pub mod digital_pointer;
|
||||
pub mod draws;
|
||||
pub mod eud;
|
||||
pub mod gps;
|
||||
pub mod message;
|
||||
|
||||
@@ -10,9 +10,6 @@ pub struct LogPayload {
|
||||
impl FromArma for LogPayload {
|
||||
fn from_arma(data: String) -> Result<LogPayload, FromArmaError> {
|
||||
let (status, message) = <(String, String)>::from_arma(data)?;
|
||||
Ok(Self {
|
||||
status,
|
||||
message
|
||||
})
|
||||
Ok(Self { 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"
|
||||
}
|
||||
|
||||
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();
|
||||
send_payload(ctx, payload);
|
||||
|
||||
"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();
|
||||
send_payload(ctx, payload);
|
||||
|
||||
"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 payload = message_cot.to_xml();
|
||||
send_payload(ctx, payload);
|
||||
|
||||
@@ -2,7 +2,10 @@ use arma_rs::Context;
|
||||
|
||||
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 now = chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Millis, true);
|
||||
let stale = (chrono::Utc::now() + chrono::Duration::days(1))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::init;
|
||||
use uuid::Uuid;
|
||||
use std::vec;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[test]
|
||||
fn uuid_output_is_uuid4_identifier() {
|
||||
@@ -17,9 +17,9 @@ mod tests {
|
||||
#[test]
|
||||
fn uuid_output_throws_if_passed_args() {
|
||||
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));
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
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();
|
||||
send_payload(ctx, payload);
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
pub mod uuid;
|
||||
pub mod address;
|
||||
pub mod log;
|
||||
pub mod uuid;
|
||||
|
||||
@@ -16,7 +16,13 @@ lazy_static! {
|
||||
#[cfg(target_os = "windows")]
|
||||
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() {
|
||||
format!("rtsp://{}:{}/{}", address, port, stream_path)
|
||||
} 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"))]
|
||||
fn spawn_ffmpeg(
|
||||
rtsp_url: String,
|
||||
stop_rx: Receiver<()>,
|
||||
status_tx: Sender<Result<(), String>>,
|
||||
) {
|
||||
fn spawn_ffmpeg(rtsp_url: String, stop_rx: Receiver<()>, status_tx: Sender<Result<(), String>>) {
|
||||
thread::spawn(move || {
|
||||
let mut cmd = Command::new("ffmpeg");
|
||||
cmd.args(&[
|
||||
"-f","x11grab",
|
||||
"-framerate","30",
|
||||
"-video_size","1920x1080",
|
||||
"-i" ,":0",
|
||||
"-f","rtsp",
|
||||
"-rtsp_transport","tcp",
|
||||
"-f",
|
||||
"x11grab",
|
||||
"-framerate",
|
||||
"30",
|
||||
"-video_size",
|
||||
"1920x1080",
|
||||
"-i",
|
||||
":0",
|
||||
"-f",
|
||||
"rtsp",
|
||||
"-rtsp_transport",
|
||||
"tcp",
|
||||
&rtsp_url,
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user