From 0f5b1130bcb62c0dd3141f3fe02b22f93b843277 Mon Sep 17 00:00:00 2001 From: Valmo Trindade Date: Sun, 8 Sep 2024 03:15:25 -0300 Subject: [PATCH] refactored get uuid fuction on extension --- Cargo.lock | 107 ++++++++++++++++++ Cargo.toml | 9 ++ .../extract_data/fn_extract_uuid.sqf | 2 +- src/lib.rs | 37 +++--- 4 files changed, 132 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a439fd..820c19c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,9 +43,17 @@ name = "armatak" version = "0.1.0" dependencies = [ "arma-rs", + "regex", "serde", + "uuid", ] +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "cc" version = "1.1.16" @@ -89,6 +97,17 @@ dependencies = [ "windows 0.48.0", ] +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "itoa" version = "1.0.11" @@ -177,6 +196,15 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -195,6 +223,36 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "regex" version = "1.10.6" @@ -413,12 +471,40 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "uuid" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +dependencies = [ + "getrandom", + "rand", + "uuid-macro-internal", +] + +[[package]] +name = "uuid-macro-internal" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee1cd046f83ea2c4e920d6ee9f7c3537ef928d75dce5d84a87c2c5d6b3999a3a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "valuable" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "winapi" version = "0.3.9" @@ -525,3 +611,24 @@ name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index 33dbcdb..ea3a712 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,17 @@ edition = "2021" [dependencies] arma-rs = "1.10.4" +regex = "1.10.6" serde = { version = "1.0.210", features = ["derive"] } +[dependencies.uuid] +version = "1.10.0" +features = [ + "v4", # Lets you generate random UUIDs + "fast-rng", # Use a faster (but still sufficiently random) RNG + "macro-diagnostics", # Enable better diagnostics for compile-time UUIDs +] + [lib] name = "armatak" crate-type = ["cdylib"] diff --git a/addons/main/functions/extract_data/fn_extract_uuid.sqf b/addons/main/functions/extract_data/fn_extract_uuid.sqf index da06ee4..be529e5 100644 --- a/addons/main/functions/extract_data/fn_extract_uuid.sqf +++ b/addons/main/functions/extract_data/fn_extract_uuid.sqf @@ -3,7 +3,7 @@ params["_unit"]; _uuid = _unit getVariable "_atak_uid"; if (isNil "_uuid") then { - _uuid = "armatak" callExtension "get_uid"; + _uuid = "armatak" callExtension "uuid"; _unit setVariable ["_atak_uid", _uuid]; }; diff --git a/src/lib.rs b/src/lib.rs index 2bd3a29..777c827 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,9 @@ use arma_rs::{arma, Extension, Group}; #[arma] -fn init() -> Extension { +pub fn init() -> Extension { Extension::build() + .command("uuid", get_uuid) .group( "markers", Group::new() @@ -20,43 +21,35 @@ fn init() -> Extension { .finish() } -#[derive(Debug, Clone)] -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, +mod tests; +mod structs; + +fn get_uuid() -> String { + use uuid::Uuid; + + Uuid::new_v4().to_string() } mod markers { pub fn get(placeholder: String) -> String { - format!("Not implemented yet, {}", placeholder) + format!("ERROR: Not implemented yet, {}", placeholder) } pub fn post(placeholder: String) -> String { - format!("Not implemented yet, {}", placeholder) + format!("ERROR: Not implemented yet, {}", placeholder) } pub fn delete(placeholder: String) -> String { - format!("Not implemented yet, {}", placeholder) + format!("ERROR: Not implemented yet, {}", placeholder) } } mod casevac { pub fn get(placeholder: String) -> String { - format!("Not implemented yet, {}", placeholder) + format!("ERROR: Not implemented yet, {}", placeholder) } pub fn post(placeholder: String) -> String { - format!("Not implemented yet, {}", placeholder) + format!("ERROR: Not implemented yet, {}", placeholder) } pub fn delete(placeholder: String) -> String { - format!("Not implemented yet, {}", placeholder) + format!("ERROR: Not implemented yet, {}", placeholder) } }