From 1eb004a0de54e6f32e08cdfb9699cfce296b6f03 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 9 May 2024 14:36:03 -0600 Subject: [PATCH 01/12] wip menu --- sh-frontend/src/app/live.rs | 13 ++++++------- sh-frontend/src/components/help.rs | 10 +++++++--- sh-frontend/src/components/mod.rs | 2 ++ sh-frontend/src/components/nav.rs | 1 - sh-frontend/src/components/settings.rs | 2 +- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/sh-frontend/src/app/live.rs b/sh-frontend/src/app/live.rs index 8262c69..c357340 100644 --- a/sh-frontend/src/app/live.rs +++ b/sh-frontend/src/app/live.rs @@ -4,7 +4,9 @@ // https://opensource.org/licenses/MIT. use crate::components::acars_messages::AcarsMessages; +use crate::components::help::ShHelp; use crate::components::map_display::ShMap; +use crate::components::settings::ShSettings; use gloo::storage::LocalStorage; use gloo_storage::Storage; use yew::prelude::*; @@ -122,7 +124,6 @@ impl Panels { /// Home page #[function_component(Live)] pub fn live() -> Html { - log::debug!("Rendering Live page"); // Grab the current panel state from storage: let left_panel = use_state(|| { let panel: Option = LocalStorage::get("left_panel").unwrap_or_default(); @@ -144,8 +145,8 @@ pub fn live() -> Html { match *right_panel { Panels::Messages => html! { }, Panels::Map => html! { }, - Panels::Settings => html! {
{"Settings"}
}, - Panels::Help => html! {
{"Help"}
}, + Panels::Settings => html! { }, + Panels::Help => html! { }, Panels::None => html! {
{"None"}
}, } }; @@ -154,15 +155,13 @@ pub fn live() -> Html { match *left_panel { Panels::Messages => html! { }, Panels::Map => html! { }, - Panels::Settings => html! {
{"Settings"}
}, - Panels::Help => html! {
{"Help"}
}, + Panels::Settings => html! { }, + Panels::Help => html! { }, Panels::None => html! {
{"None"}
}, } }; use_event_with_window("keydown", move |e: KeyboardEvent| { - log::debug!("Key pressed: {}", e.key()); - let right_panel = right_panel.clone(); let left_panel = left_panel.clone(); diff --git a/sh-frontend/src/components/help.rs b/sh-frontend/src/components/help.rs index 240edcd..d1000c6 100644 --- a/sh-frontend/src/components/help.rs +++ b/sh-frontend/src/components/help.rs @@ -5,10 +5,14 @@ use yew::prelude::*; -/// About page -#[function_component(Help)] +/// Help page +#[function_component(ShHelp)] pub fn help() -> Html { html! { - {"Placeholder"} +
+

{"SDR-E Hub Help"}

+ // TODO: Write help content +

{"Welcome to SDR-E Hub help."}

+
} } diff --git a/sh-frontend/src/components/mod.rs b/sh-frontend/src/components/mod.rs index 883dcda..09f8792 100644 --- a/sh-frontend/src/components/mod.rs +++ b/sh-frontend/src/components/mod.rs @@ -5,7 +5,9 @@ pub mod acars_messages; pub mod control; +pub mod help; pub mod map; pub mod map_display; pub mod nav; pub mod search; +pub mod settings; diff --git a/sh-frontend/src/components/nav.rs b/sh-frontend/src/components/nav.rs index 6c4709c..a7edae1 100644 --- a/sh-frontend/src/components/nav.rs +++ b/sh-frontend/src/components/nav.rs @@ -68,7 +68,6 @@ pub fn nav() -> Html { let hidden_menu = { let menu_state = *menu_state; - log::info!("Menu state: {menu_state}"); menu_state }; diff --git a/sh-frontend/src/components/settings.rs b/sh-frontend/src/components/settings.rs index 69a8ea4..3f107ab 100644 --- a/sh-frontend/src/components/settings.rs +++ b/sh-frontend/src/components/settings.rs @@ -6,7 +6,7 @@ use yew::prelude::*; /// Home page -#[function_component(Settings)] +#[function_component(ShSettings)] pub fn settings() -> Html { html! { { From 48743da7ea39631a7c16c6b02c785c52936a5213 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sat, 11 May 2024 03:04:10 -0600 Subject: [PATCH 02/12] wip --- sh-frontend/src/app/live.rs | 69 ++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/sh-frontend/src/app/live.rs b/sh-frontend/src/app/live.rs index c357340..4926405 100644 --- a/sh-frontend/src/app/live.rs +++ b/sh-frontend/src/app/live.rs @@ -10,7 +10,7 @@ use crate::components::settings::ShSettings; use gloo::storage::LocalStorage; use gloo_storage::Storage; use yew::prelude::*; -use yew_hooks::use_event_with_window; +use yew_hooks::{use_event_with_window, use_visible}; #[derive(Debug, Clone, Copy, Eq, PartialEq)] enum Panels { @@ -124,6 +124,9 @@ impl Panels { /// Home page #[function_component(Live)] pub fn live() -> Html { + let node = use_node_ref(); + let visible = use_visible(node.clone(), false); + // Grab the current panel state from storage: let left_panel = use_state(|| { let panel: Option = LocalStorage::get("left_panel").unwrap_or_default(); @@ -140,6 +143,18 @@ pub fn live() -> Html { } }); + // lets make sure left and right panels are not the same + // We'll enter this state if we're transitioning from a single panel to a dual panel + + if visible && *left_panel == *right_panel { + left_panel.set(left_panel.next(*right_panel)); + LocalStorage::set( + "left_panel", + left_panel.next(*right_panel).to_string().as_str(), + ) + .unwrap(); + } + let right_panel_status = { let right_panel = right_panel.clone(); match *right_panel { @@ -147,7 +162,7 @@ pub fn live() -> Html { Panels::Map => html! { }, Panels::Settings => html! { }, Panels::Help => html! { }, - Panels::None => html! {
{"None"}
}, + Panels::None => panic!("Right Panel is none!!!"), } }; @@ -157,52 +172,64 @@ pub fn live() -> Html { Panels::Map => html! { }, Panels::Settings => html! { }, Panels::Help => html! { }, - Panels::None => html! {
{"None"}
}, + Panels::None => panic!("Left Panel is none!!!"), } }; + let right_panel_clone = right_panel.clone(); + use_event_with_window("keydown", move |e: KeyboardEvent| { - let right_panel = right_panel.clone(); let left_panel = left_panel.clone(); // if control is pressed, with left arrow, go to the previous panel - if e.key() == "F1" { - right_panel.set(right_panel.previous(*left_panel)); + if visible && e.key() == "F1" { + right_panel_clone.set(right_panel_clone.previous(*left_panel)); LocalStorage::set( "right_panel", - right_panel.previous(*left_panel).to_string().as_str(), + right_panel_clone.previous(*left_panel).to_string().as_str(), ) .unwrap(); } // if control is pressed, with right arrow, go to the next panel - if e.key() == "F2" { - right_panel.set(right_panel.next(*left_panel)); + if visible && e.key() == "F2" { + right_panel_clone.set(right_panel_clone.next(*left_panel)); LocalStorage::set( "right_panel", - right_panel.next(*left_panel).to_string().as_str(), + right_panel_clone.next(*left_panel).to_string().as_str(), ) .unwrap(); } // if alt is pressed, with left arrow, go to the previous panel if e.key() == "F3" { - left_panel.set(left_panel.previous(*right_panel)); + log::info!("Previous left panel"); + let previous = if visible { + *right_panel_clone + } else { + Panels::None + }; + + left_panel.set(left_panel.previous(previous)); LocalStorage::set( "left_panel", - left_panel.previous(*right_panel).to_string().as_str(), + left_panel.previous(previous).to_string().as_str(), ) .unwrap(); } // if alt is pressed, with right arrow, go to the next panel if e.key() == "F4" { - left_panel.set(left_panel.next(*right_panel)); - LocalStorage::set( - "left_panel", - left_panel.next(*right_panel).to_string().as_str(), - ) - .unwrap(); + log::info!("Next left panel"); + let previous = if visible { + *right_panel_clone + } else { + Panels::None + }; + + left_panel.set(left_panel.next(previous)); + LocalStorage::set("left_panel", left_panel.next(previous).to_string().as_str()) + .unwrap(); } }); @@ -211,8 +238,10 @@ pub fn live() -> Html {
{ left_panel_show.clone() }
- } From 3020f08988e50ac4755d916b3c5aeec7606865d0 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sun, 12 May 2024 00:45:02 -0600 Subject: [PATCH 03/12] Update live.rs --- sh-frontend/src/app/live.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/sh-frontend/src/app/live.rs b/sh-frontend/src/app/live.rs index 4926405..7a6caac 100644 --- a/sh-frontend/src/app/live.rs +++ b/sh-frontend/src/app/live.rs @@ -203,7 +203,6 @@ pub fn live() -> Html { // if alt is pressed, with left arrow, go to the previous panel if e.key() == "F3" { - log::info!("Previous left panel"); let previous = if visible { *right_panel_clone } else { @@ -220,7 +219,6 @@ pub fn live() -> Html { // if alt is pressed, with right arrow, go to the next panel if e.key() == "F4" { - log::info!("Next left panel"); let previous = if visible { *right_panel_clone } else { From d963d24346ad07b95b55b996a83225713dcad8dd Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sun, 12 May 2024 00:49:44 -0600 Subject: [PATCH 04/12] Update live.rs --- sh-frontend/src/app/live.rs | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/sh-frontend/src/app/live.rs b/sh-frontend/src/app/live.rs index 7a6caac..1cb1380 100644 --- a/sh-frontend/src/app/live.rs +++ b/sh-frontend/src/app/live.rs @@ -155,6 +155,9 @@ pub fn live() -> Html { .unwrap(); } + // FIXME: We probably shouldn't panic here, and instead alert the user that something went wrong + // and reset the panels to a default state. + let right_panel_status = { let right_panel = right_panel.clone(); match *right_panel { @@ -177,26 +180,31 @@ pub fn live() -> Html { }; let right_panel_clone = right_panel.clone(); + let left_panel_clone = left_panel.clone(); use_event_with_window("keydown", move |e: KeyboardEvent| { - let left_panel = left_panel.clone(); - // if control is pressed, with left arrow, go to the previous panel if visible && e.key() == "F1" { - right_panel_clone.set(right_panel_clone.previous(*left_panel)); + right_panel_clone.set(right_panel_clone.previous(*left_panel_clone)); LocalStorage::set( "right_panel", - right_panel_clone.previous(*left_panel).to_string().as_str(), + right_panel_clone + .previous(*left_panel_clone) + .to_string() + .as_str(), ) .unwrap(); } // if control is pressed, with right arrow, go to the next panel if visible && e.key() == "F2" { - right_panel_clone.set(right_panel_clone.next(*left_panel)); + right_panel_clone.set(right_panel_clone.next(*left_panel_clone)); LocalStorage::set( "right_panel", - right_panel_clone.next(*left_panel).to_string().as_str(), + right_panel_clone + .next(*left_panel_clone) + .to_string() + .as_str(), ) .unwrap(); } @@ -209,10 +217,10 @@ pub fn live() -> Html { Panels::None }; - left_panel.set(left_panel.previous(previous)); + left_panel_clone.set(left_panel_clone.previous(previous)); LocalStorage::set( "left_panel", - left_panel.previous(previous).to_string().as_str(), + left_panel_clone.previous(previous).to_string().as_str(), ) .unwrap(); } @@ -225,9 +233,12 @@ pub fn live() -> Html { Panels::None }; - left_panel.set(left_panel.next(previous)); - LocalStorage::set("left_panel", left_panel.next(previous).to_string().as_str()) - .unwrap(); + left_panel_clone.set(left_panel_clone.next(previous)); + LocalStorage::set( + "left_panel", + left_panel_clone.next(previous).to_string().as_str(), + ) + .unwrap(); } }); From df7f188dcb67cd75a4a47703fda3ff4a7d4a541b Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 13 May 2024 09:17:24 -0600 Subject: [PATCH 05/12] wip --- sh-frontend/Cargo.lock | 46 ++++++++++++++++++++++++ sh-frontend/Cargo.toml | 3 ++ sh-frontend/src/lib.rs | 1 + sh-frontend/src/services/mod.rs | 1 + sh-frontend/src/services/websocket.rs | 52 +++++++++++++++++++++++++++ 5 files changed, 103 insertions(+) create mode 100644 sh-frontend/src/services/mod.rs create mode 100644 sh-frontend/src/services/websocket.rs diff --git a/sh-frontend/Cargo.lock b/sh-frontend/Cargo.lock index ff2d5d2..d277ae0 100644 --- a/sh-frontend/Cargo.lock +++ b/sh-frontend/Cargo.lock @@ -196,6 +196,7 @@ checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", + "futures-executor", "futures-io", "futures-sink", "futures-task", @@ -218,6 +219,17 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" version = "0.3.30" @@ -465,6 +477,26 @@ dependencies = [ "web-sys", ] +[[package]] +name = "gloo-net" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2899cb1a13be9020b010967adc6b2a8a343b6f1428b90238c9d53ca24decc6db" +dependencies = [ + "futures-channel", + "futures-core", + "futures-sink", + "gloo-utils 0.1.7", + "js-sys", + "pin-project", + "serde", + "serde_json", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "gloo-net" version = "0.3.1" @@ -1188,6 +1220,15 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "reqwasm" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b89870d729c501fa7a68c43bf4d938bbb3a8c156d333d90faa0e8b3e3212fb" +dependencies = [ + "gloo-net 0.1.0", +] + [[package]] name = "reqwest" version = "0.12.4" @@ -1390,14 +1431,17 @@ dependencies = [ name = "sh-frontend" version = "4.0.0-alpha.1" dependencies = [ + "futures", "gloo 0.11.0", "gloo-storage 0.3.0", "gloo-utils 0.2.0", "leaflet", "log", + "reqwasm", "reqwest", "serde", "wasm-bindgen", + "wasm-bindgen-futures", "wasm-bindgen-test", "wasm-logger", "web-sys", @@ -1731,6 +1775,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", + "serde", + "serde_json", "wasm-bindgen-macro", ] diff --git a/sh-frontend/Cargo.toml b/sh-frontend/Cargo.toml index cc816af..90ffa1f 100644 --- a/sh-frontend/Cargo.toml +++ b/sh-frontend/Cargo.toml @@ -38,17 +38,20 @@ categories = ["aerospace"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +futures = "0.3.30" gloo = "0.11.0" gloo-storage = "0.3.0" gloo-utils = "0.2.0" leaflet = "0.4.0" log = "0.4.21" serde = "1.0.201" +reqwasm = "0.5.0" reqwest = { version = "0.12.4", features = ["json"] } yew = { version = "0.21.0", features = ["csr"] } yew-router = "0.18.0" yew-hooks = "0.3.1" wasm-bindgen = "0.2.92" +wasm-bindgen-futures = "0.4.42" wasm-logger = "0.2.0" web-sys = { version = "0.3.69", features = [ "Document", diff --git a/sh-frontend/src/lib.rs b/sh-frontend/src/lib.rs index 87db832..5e2bbbc 100644 --- a/sh-frontend/src/lib.rs +++ b/sh-frontend/src/lib.rs @@ -14,3 +14,4 @@ pub mod app; pub mod components; +pub mod services; diff --git a/sh-frontend/src/services/mod.rs b/sh-frontend/src/services/mod.rs new file mode 100644 index 0000000..6eba44d --- /dev/null +++ b/sh-frontend/src/services/mod.rs @@ -0,0 +1 @@ +pub mod websocket; diff --git a/sh-frontend/src/services/websocket.rs b/sh-frontend/src/services/websocket.rs new file mode 100644 index 0000000..e721f3a --- /dev/null +++ b/sh-frontend/src/services/websocket.rs @@ -0,0 +1,52 @@ +// Copyright (C) 2024 Fred Clausen +// Use of this source code is governed by an MIT-style +// license that can be found in the LICENSE file or at +// https://opensource.org/licenses/MIT. + +use futures::{channel::mpsc::Sender, SinkExt, StreamExt}; +use reqwasm::websocket::{futures::WebSocket, Message}; + +use wasm_bindgen_futures::spawn_local; + +pub struct WebsocketService { + pub tx: Sender, +} + +impl WebsocketService { + pub fn new() -> Self { + let ws = WebSocket::open("ws://127.0.0.1:8080").unwrap(); + + let (mut write, mut read) = ws.split(); + + let (in_tx, mut in_rx) = futures::channel::mpsc::channel::(1000); + + spawn_local(async move { + while let Some(s) = in_rx.next().await { + log::debug!("got event from channel! {}", s); + write.send(Message::Text(s)).await.unwrap(); + } + }); + + spawn_local(async move { + while let Some(msg) = read.next().await { + match msg { + Ok(Message::Text(data)) => { + log::debug!("from websocket: {}", data); + } + Ok(Message::Bytes(b)) => { + let decoded = std::str::from_utf8(&b); + if let Ok(val) = decoded { + log::debug!("from websocket: {}", val); + } + } + Err(e) => { + log::error!("ws: {:?}", e) + } + } + } + log::debug!("WebSocket Closed"); + }); + + Self { tx: in_tx } + } +} From 246c88b957496b0b16ed148d0b745c84461b8d5e Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 13 May 2024 11:20:18 -0600 Subject: [PATCH 06/12] updates --- .github/workflows/deploy.yml | 10 +++++----- .github/workflows/markdownlint.yml | 2 +- .github/workflows/on_pr.yaml | 14 +++++++------- .github/workflows/pre-commit-updates.yaml | 2 +- .github/workflows/yamllint.yml | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e2e32fb..5fe8ce7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -55,7 +55,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4.1.3 + uses: actions/checkout@v4.1.5 with: fetch-depth: 0 @@ -95,7 +95,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4.1.3 + uses: actions/checkout@v4.1.5 with: fetch-depth: 0 @@ -134,7 +134,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4.1.3 + uses: actions/checkout@v4.1.5 with: fetch-depth: 0 @@ -172,7 +172,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4.1.2 + uses: actions/checkout@v4.1.5 with: fetch-depth: 0 @@ -269,7 +269,7 @@ jobs: github.event.inputs.build_latest_as_test == '' ) runs-on: ${{ matrix.platform }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.1.5 - name: setup node uses: actions/setup-node@v4 diff --git a/.github/workflows/markdownlint.yml b/.github/workflows/markdownlint.yml index c86ce0f..5b8882f 100644 --- a/.github/workflows/markdownlint.yml +++ b/.github/workflows/markdownlint.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.3 + - uses: actions/checkout@v4.1.5 - name: Pull markdownlint/markdownlint:latest Image run: docker pull markdownlint/markdownlint:latest - name: Run markdownlint against *.md files diff --git a/.github/workflows/on_pr.yaml b/.github/workflows/on_pr.yaml index afa36bd..8e30318 100644 --- a/.github/workflows/on_pr.yaml +++ b/.github/workflows/on_pr.yaml @@ -23,7 +23,7 @@ jobs: name: "Linting: hadolint" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.3 + - uses: actions/checkout@v4.1.5 - name: Pull hadolint/hadolint:latest Image run: docker pull hadolint/hadolint:latest - name: Run hadolint against Dockerfiles @@ -35,7 +35,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4.1.3 + uses: actions/checkout@v4.1.5 with: fetch-depth: 0 @@ -59,7 +59,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4.1.3 + uses: actions/checkout@v4.1.5 with: fetch-depth: 0 @@ -99,7 +99,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4.1.3 + uses: actions/checkout@v4.1.5 with: fetch-depth: 0 @@ -139,7 +139,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4.1.3 + uses: actions/checkout@v4.1.5 with: fetch-depth: 0 @@ -178,7 +178,7 @@ jobs: needs: [test_rust_functionality] steps: - name: Checkout - uses: actions/checkout@v4.1.2 + uses: actions/checkout@v4.1.5 with: fetch-depth: 0 @@ -283,7 +283,7 @@ jobs: runs-on: ${{ matrix.platform }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.1.5 - name: setup node uses: actions/setup-node@v4 diff --git a/.github/workflows/pre-commit-updates.yaml b/.github/workflows/pre-commit-updates.yaml index ce1fd47..7920e29 100644 --- a/.github/workflows/pre-commit-updates.yaml +++ b/.github/workflows/pre-commit-updates.yaml @@ -9,7 +9,7 @@ jobs: update: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.3 + - uses: actions/checkout@v4.1.5 with: fetch-depth: 0 - uses: vrslev/pre-commit-autoupdate@v1.0.0 diff --git a/.github/workflows/yamllint.yml b/.github/workflows/yamllint.yml index 72aaed1..c4504ca 100644 --- a/.github/workflows/yamllint.yml +++ b/.github/workflows/yamllint.yml @@ -15,7 +15,7 @@ jobs: name: Run yamllint against YAML files runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.3 + - uses: actions/checkout@v4.1.5 - name: yaml-lint uses: ibiqlik/action-yamllint@v3 with: From 636f2fac8f4978474a417133fbe6fa121e01e8b9 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 13 May 2024 13:15:20 -0600 Subject: [PATCH 07/12] wip --- .github/workflows/deploy.yml | 38 ++++++++++---------- .github/workflows/on_pr.yaml | 38 ++++++++++---------- .github/workflows/pre-commit-updates.yaml | 2 +- .github/workflows/yamllint.yml | 2 +- sh-frontend/src/app/mod.rs | 42 ++++++++++++++++------- sh-frontend/src/services/websocket.rs | 2 +- 6 files changed, 70 insertions(+), 54 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5fe8ce7..1077c3c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -60,20 +60,20 @@ jobs: fetch-depth: 0 - name: Run Docker on tmpfs - uses: JonasAlfredsson/docker-on-tmpfs@v1 + uses: JonasAlfredsson/docker-on-tmpfs@v1.0.1 with: tmpfs_size: 5 swap_size: 4 swap_location: "/mnt/swapfile" - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v3.3.0 - name: Build armv7 - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v5.3.0 with: context: . push: false @@ -100,20 +100,20 @@ jobs: fetch-depth: 0 - name: Run Docker on tmpfs - uses: JonasAlfredsson/docker-on-tmpfs@v1 + uses: JonasAlfredsson/docker-on-tmpfs@v1.0.1 with: tmpfs_size: 5 swap_size: 4 swap_location: "/mnt/swapfile" - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v3.3.0 - name: Build arm64 - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v5.3.0 with: context: . push: false @@ -139,20 +139,20 @@ jobs: fetch-depth: 0 - name: Run Docker on tmpfs - uses: JonasAlfredsson/docker-on-tmpfs@v1 + uses: JonasAlfredsson/docker-on-tmpfs@v1.0.1 with: tmpfs_size: 5 swap_size: 4 swap_location: "/mnt/swapfile" - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v3.3.0 - name: Build amd64 - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v5.3.0 with: context: . push: false @@ -177,20 +177,20 @@ jobs: fetch-depth: 0 - name: Run Docker on tmpfs - uses: JonasAlfredsson/docker-on-tmpfs@v1 + uses: JonasAlfredsson/docker-on-tmpfs@v1.0.1 with: tmpfs_size: 5 swap_size: 4 swap_location: "/mnt/swapfile" - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v3.3.0 - name: Build amd64 - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v5.3.0 with: context: . push: false @@ -241,7 +241,7 @@ jobs: - run: ls -la */* - name: Cache Binaries - uses: actions/cache@v4 + uses: actions/cache@v4.0.2 with: path: ./bin/ key: ${{ github.run_id }} @@ -272,7 +272,7 @@ jobs: - uses: actions/checkout@v4.1.5 - name: setup node - uses: actions/setup-node@v4 + uses: actions/setup-node@v4.0.2 with: node-version: lts/* @@ -298,7 +298,7 @@ jobs: # - name: install frontend dependencies # run: yarn install # change this to npm, pnpm or bun depending on which one you use. - - uses: tauri-apps/tauri-action@v0 + - uses: tauri-apps/tauri-action@v0.5.3 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/.github/workflows/on_pr.yaml b/.github/workflows/on_pr.yaml index 8e30318..debd837 100644 --- a/.github/workflows/on_pr.yaml +++ b/.github/workflows/on_pr.yaml @@ -64,20 +64,20 @@ jobs: fetch-depth: 0 - name: Run Docker on tmpfs - uses: JonasAlfredsson/docker-on-tmpfs@v1 + uses: JonasAlfredsson/docker-on-tmpfs@v1.0.1 with: tmpfs_size: 5 swap_size: 4 swap_location: "/mnt/swapfile" - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v3.3.0 - name: Build armv7 - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v5.3.0 with: context: . push: false @@ -104,20 +104,20 @@ jobs: fetch-depth: 0 - name: Run Docker on tmpfs - uses: JonasAlfredsson/docker-on-tmpfs@v1 + uses: JonasAlfredsson/docker-on-tmpfs@v1.0.1 with: tmpfs_size: 5 swap_size: 4 swap_location: "/mnt/swapfile" - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v3.3.0 - name: Build arm64 - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v5.3.0 with: context: . push: false @@ -144,20 +144,20 @@ jobs: fetch-depth: 0 - name: Run Docker on tmpfs - uses: JonasAlfredsson/docker-on-tmpfs@v1 + uses: JonasAlfredsson/docker-on-tmpfs@v1.0.1 with: tmpfs_size: 5 swap_size: 4 swap_location: "/mnt/swapfile" - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v3.3.0 - name: Build amd64 - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v5.3.0 with: context: . push: false @@ -183,20 +183,20 @@ jobs: fetch-depth: 0 - name: Run Docker on tmpfs - uses: JonasAlfredsson/docker-on-tmpfs@v1 + uses: JonasAlfredsson/docker-on-tmpfs@v1.0.1 with: tmpfs_size: 5 swap_size: 4 swap_location: "/mnt/swapfile" - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v3.3.0 - name: Build amd64 - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v5.3.0 with: context: . push: false @@ -247,7 +247,7 @@ jobs: - run: ls -la */* - name: Cache Binaries - uses: actions/cache@v4 + uses: actions/cache@v4.0.2 with: path: ./bin/ key: ${{ github.run_id }} @@ -286,7 +286,7 @@ jobs: - uses: actions/checkout@v4.1.5 - name: setup node - uses: actions/setup-node@v4 + uses: actions/setup-node@v4.0.2 with: node-version: lts/* @@ -312,7 +312,7 @@ jobs: # - name: install frontend dependencies # run: yarn install # change this to npm, pnpm or bun depending on which one you use. - - uses: tauri-apps/tauri-action@v0 + - uses: tauri-apps/tauri-action@v0.5.3 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/.github/workflows/pre-commit-updates.yaml b/.github/workflows/pre-commit-updates.yaml index 7920e29..9916c6a 100644 --- a/.github/workflows/pre-commit-updates.yaml +++ b/.github/workflows/pre-commit-updates.yaml @@ -13,7 +13,7 @@ jobs: with: fetch-depth: 0 - uses: vrslev/pre-commit-autoupdate@v1.0.0 - - uses: peter-evans/create-pull-request@v6 + - uses: peter-evans/create-pull-request@v6.0.5 with: branch: pre-commit-autoupdate title: "chore(deps): Update pre-commit hooks" diff --git a/.github/workflows/yamllint.yml b/.github/workflows/yamllint.yml index c4504ca..e0bee88 100644 --- a/.github/workflows/yamllint.yml +++ b/.github/workflows/yamllint.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v4.1.5 - name: yaml-lint - uses: ibiqlik/action-yamllint@v3 + uses: ibiqlik/action-yamllint@v3.1.1 with: config_data: | extends: default diff --git a/sh-frontend/src/app/mod.rs b/sh-frontend/src/app/mod.rs index e23044c..909273d 100644 --- a/sh-frontend/src/app/mod.rs +++ b/sh-frontend/src/app/mod.rs @@ -8,7 +8,7 @@ use yew_router::prelude::*; pub mod live; -use crate::components::nav::Nav; +use crate::{components::nav::Nav, services::websocket::WebsocketService}; use live::Live; /// App routes @@ -31,17 +31,33 @@ pub fn switch(routes: ShAppRoute) -> Html { } } -/// Root app component -#[function_component(App)] -pub fn app() -> Html { - html! { - -
-
-
+pub struct App { + wss: WebsocketService, +} + +impl Component for App { + type Message = (); + type Properties = (); + + fn create(ctx: &Context) -> Self { + let wss = WebsocketService::new(); + Self { wss } + } + + fn update(&mut self, _ctx: &Context, msg: Self::Message) -> bool { + true + } + + fn view(&self, ctx: &Context) -> Html { + html! { + +
+
+
+ } } } diff --git a/sh-frontend/src/services/websocket.rs b/sh-frontend/src/services/websocket.rs index e721f3a..d43b3c2 100644 --- a/sh-frontend/src/services/websocket.rs +++ b/sh-frontend/src/services/websocket.rs @@ -14,7 +14,7 @@ pub struct WebsocketService { impl WebsocketService { pub fn new() -> Self { - let ws = WebSocket::open("ws://127.0.0.1:8080").unwrap(); + let ws = WebSocket::open("ws://127.0.0.1:3000/sdre-hub").unwrap(); let (mut write, mut read) = ws.split(); From fc654a26ad304547e1719f109b0d73468e77fa6e Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 13 May 2024 13:38:15 -0600 Subject: [PATCH 08/12] Update dependabot.yaml --- .github/dependabot.yaml | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index 2668b99..7cb5146 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -1,37 +1,32 @@ version: 2 updates: - # - package-ecosystem: "pip" - # directory: "/rootfs/webapp" - # schedule: - # interval: weekly - # assignees: - # - "fredclausen" - - # - package-ecosystem: "npm" - # directory: "/acarshub-typescript" - # schedule: - # interval: weekly - # assignees: - # - "fredclausen" - - package-ecosystem: "docker" directory: "/" schedule: - interval: weekly + interval: "weekly" + day: "saturday" + time: "00:00" + timezone: "Etc/UTC" assignees: - "fredclausen" - package-ecosystem: "github-actions" directory: "/" schedule: - interval: weekly + interval: "weekly" + day: "saturday" + time: "00:00" + timezone: "Etc/UTC" assignees: - "fredclausen" - package-ecosystem: "cargo" directory: "/" schedule: - interval: weekly + interval: "weekly" + day: "saturday" + time: "00:00" + timezone: "Etc/UTC" assignees: - "fredclausen" From e57c31e9b2c8ea6e629f62b55e1994f32d78b27d Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 14 May 2024 08:17:18 -0600 Subject: [PATCH 09/12] wip --- Cargo.lock | 3 ++ sh-frontend/src/app/mod.rs | 6 ++-- sh-frontend/src/services/websocket.rs | 2 ++ src/libraries/sdrehub/src/lib.rs | 7 ++-- src/libraries/sh-api/Cargo.toml | 3 ++ src/libraries/sh-api/src/lib.rs | 50 ++++++++++++++++++++++----- 6 files changed, 57 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7161043..91354e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3633,7 +3633,10 @@ dependencies = [ "async-trait", "axum", "log", + "serde", + "serde_json", "sh-common", + "sh-config", "tokio", ] diff --git a/sh-frontend/src/app/mod.rs b/sh-frontend/src/app/mod.rs index 909273d..ee700f1 100644 --- a/sh-frontend/src/app/mod.rs +++ b/sh-frontend/src/app/mod.rs @@ -39,16 +39,16 @@ impl Component for App { type Message = (); type Properties = (); - fn create(ctx: &Context) -> Self { + fn create(_ctx: &Context) -> Self { let wss = WebsocketService::new(); Self { wss } } - fn update(&mut self, _ctx: &Context, msg: Self::Message) -> bool { + fn update(&mut self, _ctx: &Context, _msg: Self::Message) -> bool { true } - fn view(&self, ctx: &Context) -> Html { + fn view(&self, _ctx: &Context) -> Html { html! {
diff --git a/sh-frontend/src/services/websocket.rs b/sh-frontend/src/services/websocket.rs index d43b3c2..f34c061 100644 --- a/sh-frontend/src/services/websocket.rs +++ b/sh-frontend/src/services/websocket.rs @@ -14,6 +14,8 @@ pub struct WebsocketService { impl WebsocketService { pub fn new() -> Self { + // FIXME: we should self-suss the URL from the current page + // FIXME: this should handle disconnects and reconnects let ws = WebSocket::open("ws://127.0.0.1:3000/sdre-hub").unwrap(); let (mut write, mut read) = ws.split(); diff --git a/src/libraries/sdrehub/src/lib.rs b/src/libraries/sdrehub/src/lib.rs index 17cfdb2..a2c1003 100644 --- a/src/libraries/sdrehub/src/lib.rs +++ b/src/libraries/sdrehub/src/lib.rs @@ -31,7 +31,7 @@ use sh_config::ShConfig; use tokio::task::JoinSet; pub struct SdreHub { - config: ShConfig, + config: std::sync::Arc, data_users: ShDataUserList, } @@ -39,7 +39,7 @@ impl SdreHub { #[must_use] pub fn new(config: ShConfig) -> Self { Self { - config, + config: std::sync::Arc::new(config), data_users: Vec::new(), } } @@ -57,7 +57,8 @@ impl SdreHub { // lets generate the consumers - self.data_users.push(Box::new(ShAPIServer {})); + self.data_users + .push(Box::new(ShAPIServer::new(self.config.clone()))); debug!("Starting consumers"); diff --git a/src/libraries/sh-api/Cargo.toml b/src/libraries/sh-api/Cargo.toml index 56ac8c7..eea5293 100644 --- a/src/libraries/sh-api/Cargo.toml +++ b/src/libraries/sh-api/Cargo.toml @@ -19,5 +19,8 @@ keywords.workspace = true async-trait = "0.1.80" axum = { version = "0.7.5", features = ["ws"] } log = "0.4.21" +serde = { version = "1.0.201", features = ["derive"] } +serde_json = "1.0.117" sh-common = { path = "../sh-common" } +sh-config = { path = "../sh-config" } tokio = { version = "1.37.0", features = ["full", "tracing"] } diff --git a/src/libraries/sh-api/src/lib.rs b/src/libraries/sh-api/src/lib.rs index fc58468..5d25254 100644 --- a/src/libraries/sh-api/src/lib.rs +++ b/src/libraries/sh-api/src/lib.rs @@ -19,11 +19,20 @@ use axum::{ routing::get, Router, }; +use serde::Deserialize; use sh_common::ShDataUser; +use sh_config::ShConfig; #[macro_use] extern crate log; -pub struct ShAPIServer {} +#[derive(Deserialize)] +pub enum MessageRequest { + RequestConfig, +} + +pub struct ShAPIServer { + _config: std::sync::Arc, +} #[async_trait] impl ShDataUser for ShAPIServer { @@ -43,6 +52,11 @@ impl ShDataUser for ShAPIServer { } impl ShAPIServer { + #[must_use] + pub fn new(config: std::sync::Arc) -> Self { + Self { _config: config } + } + /// # Errors /// - Error binding socket for websocket server: {e} pub async fn run_apiserver(&self) -> Result<(), Box> { @@ -88,13 +102,33 @@ async fn ws_handler(ws: WebSocketUpgrade) -> Response { async fn ws_handle_socket(mut socket: WebSocket) { while let Some(Ok(msg)) = socket.recv().await { - if let Message::Text(msg) = msg { - if socket - .send(Message::Text(format!("You said: {msg}"))) - .await - .is_err() - { - break; + // deserialize the message and see if it's a request for config + match msg { + Message::Text(text) => { + match serde_json::from_str(&text) { + Ok(MessageRequest::RequestConfig) => { + // send the config + socket + .send(Message::Text("test".to_string())) + .await + .unwrap(); + } + Err(e) => { + error!("Error deserializing message: {e}"); + } + } + } + Message::Binary(_) => { + error!("Binary messages not supported"); + } + Message::Ping(_) => { + error!("Ping messages not supported"); + } + Message::Pong(_) => { + error!("Pong messages not supported"); + } + Message::Close(_) => { + error!("Close messages not supported"); } } } From afe262e3188894059005b9e84c2359d3cfe9c5b5 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 14 May 2024 09:29:44 -0600 Subject: [PATCH 10/12] wip --- sh-frontend/Cargo.lock | 791 +++++++++++++++++++++++++++++++- sh-frontend/Cargo.toml | 6 + sh-frontend/src/app/mod.rs | 16 + src/libraries/sh-api/src/lib.rs | 72 ++- 4 files changed, 864 insertions(+), 21 deletions(-) diff --git a/sh-frontend/Cargo.lock b/sh-frontend/Cargo.lock index d277ae0..8e58ab1 100644 --- a/sh-frontend/Cargo.lock +++ b/sh-frontend/Cargo.lock @@ -17,18 +17,169 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" + +[[package]] +name = "anstyle-parse" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anymap2" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c" +[[package]] +name = "async-trait" +version = "0.1.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "atomic" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994" +dependencies = [ + "bytemuck", +] + [[package]] name = "autocfg" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +[[package]] +name = "axum" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +dependencies = [ + "async-trait", + "axum-core", + "base64 0.21.7", + "bytes", + "futures-util", + "http 1.1.0", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sha1", + "sync_wrapper 1.0.1", + "tokio", + "tokio-tungstenite", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.1.0", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 0.1.2", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "backtrace" version = "0.3.71" @@ -44,6 +195,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "base64" version = "0.22.0" @@ -71,6 +228,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "boolinator" version = "2.4.0" @@ -83,6 +249,18 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "bytemuck" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "bytes" version = "1.6.0" @@ -101,6 +279,26 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets 0.52.5", +] + +[[package]] +name = "colorchoice" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -127,6 +325,62 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "directories" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "encoding_rs" version = "0.8.34" @@ -136,6 +390,29 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -158,6 +435,20 @@ version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +[[package]] +name = "figment" +version = "0.10.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d032832d74006f99547004d49410a4b4218e4c33382d56ca3ff89df74f86b953" +dependencies = [ + "atomic", + "pear", + "serde", + "toml", + "uncased", + "version_check", +] + [[package]] name = "fnv" version = "1.0.7" @@ -277,6 +568,16 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.14" @@ -807,6 +1108,18 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "1.3.1" @@ -820,6 +1133,7 @@ dependencies = [ "http 1.1.0", "http-body", "httparse", + "httpdate", "itoa", "pin-project-lite", "smallvec", @@ -863,6 +1177,29 @@ dependencies = [ "tracing", ] +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "idna" version = "0.5.0" @@ -903,12 +1240,24 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "inlinable_string" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" + [[package]] name = "ipnet" version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itoa" version = "1.0.11" @@ -949,18 +1298,44 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.5.0", + "libc", +] + [[package]] name = "linux-raw-sys" version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + [[package]] name = "memchr" version = "2.7.2" @@ -1011,6 +1386,15 @@ dependencies = [ "tempfile", ] +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -1080,12 +1464,64 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "parking_lot" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.5", +] + [[package]] name = "paste" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "pear" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdeeaa00ce488657faba8ebf44ab9361f9365a97bd39ffb8a60663f57ff4b467" +dependencies = [ + "inlinable_string", + "pear_codegen", + "yansi", +] + +[[package]] +name = "pear_codegen" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bab5b985dc082b345f812b7df84e1bef27e7207b39e448439ba8bd69c93f147" +dependencies = [ + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn 2.0.60", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -1141,6 +1577,12 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "prettyplease" version = "0.2.19" @@ -1158,7 +1600,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", ] [[package]] @@ -1194,6 +1636,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", + "version_check", + "yansi", +] + [[package]] name = "prokio" version = "0.1.0" @@ -1220,6 +1675,85 @@ 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 = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags 2.5.0", +] + +[[package]] +name = "redox_users" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + [[package]] name = "reqwasm" version = "0.5.0" @@ -1235,7 +1769,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" dependencies = [ - "base64", + "base64 0.22.0", "bytes", "encoding_rs", "futures-core", @@ -1259,7 +1793,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", "tokio-native-tls", @@ -1302,7 +1836,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64", + "base64 0.22.0", "rustls-pki-types", ] @@ -1339,6 +1873,24 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sdre-rust-logging" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b3028f94704eb1ca2606a3dff00e9bb97b82f43f13aeda1d0a50b827bc4ac0" +dependencies = [ + "anstyle", + "chrono", + "env_logger", + "log", +] + [[package]] name = "security-framework" version = "2.10.0" @@ -1371,6 +1923,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-inline-default" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9980133dc534d02ab08df3b384295223a45090c40a4c46240e3eaa982b495910" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "serde-wasm-bindgen" version = "0.5.0" @@ -1406,15 +1969,34 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", "serde", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" +dependencies = [ + "itoa", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1427,6 +2009,41 @@ dependencies = [ "serde", ] +[[package]] +name = "sh-api" +version = "4.0.0-alpha.1" +dependencies = [ + "async-trait", + "axum", + "log", + "serde", + "serde_json", + "sh-common", + "sh-config", + "tokio", +] + +[[package]] +name = "sh-common" +version = "4.0.0-alpha.1" +dependencies = [ + "async-trait", +] + +[[package]] +name = "sh-config" +version = "4.0.0-alpha.1" +dependencies = [ + "directories", + "figment", + "log", + "sdre-rust-logging", + "serde", + "serde-inline-default", + "toml", + "void", +] + [[package]] name = "sh-frontend" version = "4.0.0-alpha.1" @@ -1440,6 +2057,8 @@ dependencies = [ "reqwasm", "reqwest", "serde", + "serde_json", + "sh-api", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test", @@ -1450,6 +2069,26 @@ dependencies = [ "yew-router", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + [[package]] name = "slab" version = "0.4.9" @@ -1502,6 +2141,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "system-configuration" version = "0.5.1" @@ -1580,11 +2225,27 @@ dependencies = [ "bytes", "libc", "mio", + "num_cpus", + "parking_lot", "pin-project-lite", + "signal-hook-registry", "socket2", + "tokio-macros", + "tracing", "windows-sys 0.48.0", ] +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "tokio-native-tls" version = "0.3.1" @@ -1606,6 +2267,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite", +] + [[package]] name = "tokio-util" version = "0.7.10" @@ -1620,11 +2293,26 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.12", +] + [[package]] name = "toml_datetime" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -1634,7 +2322,20 @@ checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap", "toml_datetime", - "winnow", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.6.8", ] [[package]] @@ -1703,6 +2404,40 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.1.0", + "httparse", + "log", + "rand", + "sha1", + "thiserror", + "url", + "utf-8", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "uncased" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.15" @@ -1741,6 +2476,18 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "vcpkg" version = "0.2.15" @@ -1753,6 +2500,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + [[package]] name = "want" version = "0.3.1" @@ -1882,6 +2635,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.5", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -2030,6 +2792,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.52.0" @@ -2040,6 +2811,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + [[package]] name = "yew" version = "0.21.0" diff --git a/sh-frontend/Cargo.toml b/sh-frontend/Cargo.toml index 90ffa1f..a09501a 100644 --- a/sh-frontend/Cargo.toml +++ b/sh-frontend/Cargo.toml @@ -34,6 +34,7 @@ keywords = [ "api", ] categories = ["aerospace"] +resolver = "2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -45,6 +46,7 @@ gloo-utils = "0.2.0" leaflet = "0.4.0" log = "0.4.21" serde = "1.0.201" +serde_json = "1.0.117" reqwasm = "0.5.0" reqwest = { version = "0.12.4", features = ["json"] } yew = { version = "0.21.0", features = ["csr"] } @@ -60,6 +62,10 @@ web-sys = { version = "0.3.69", features = [ "KeyboardEvent", ] } +sh-api = { path = "../src/libraries/sh-api" } + [dev-dependencies] wasm-bindgen-test = "0.3.42" gloo-utils = "0.2.0" + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/sh-frontend/src/app/mod.rs b/sh-frontend/src/app/mod.rs index ee700f1..81c37bc 100644 --- a/sh-frontend/src/app/mod.rs +++ b/sh-frontend/src/app/mod.rs @@ -3,6 +3,7 @@ // license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. +use sh_api::{MessageData, UserMessageTypes, UserWssMessage}; use yew::prelude::*; use yew_router::prelude::*; @@ -41,6 +42,21 @@ impl Component for App { fn create(_ctx: &Context) -> Self { let wss = WebsocketService::new(); + let message = UserWssMessage::new(UserMessageTypes::UserRequestConfig, MessageData::None); + + match serde_json::to_string(&message) { + Ok(message) => { + if let Ok(_) = wss.tx.clone().try_send(message) { + log::info!("Sent message to server"); + } else { + log::error!("Failed to send message to server"); + } + } + Err(e) => { + log::error!("Error serializing message: {}", e); + } + } + Self { wss } } diff --git a/src/libraries/sh-api/src/lib.rs b/src/libraries/sh-api/src/lib.rs index 5d25254..4378d4f 100644 --- a/src/libraries/sh-api/src/lib.rs +++ b/src/libraries/sh-api/src/lib.rs @@ -19,15 +19,52 @@ use axum::{ routing::get, Router, }; -use serde::Deserialize; +use serde::{Deserialize, Serialize}; use sh_common::ShDataUser; use sh_config::ShConfig; #[macro_use] extern crate log; -#[derive(Deserialize)] -pub enum MessageRequest { - RequestConfig, +#[derive(Serialize, Deserialize)] +pub enum UserMessageTypes { + UserRequestConfig, +} + +#[derive(Serialize, Deserialize)] +pub enum ServerMessageTypes { + ServerResponseConfig, +} + +#[derive(Deserialize, Serialize)] +pub enum MessageData { + Config(String), + None, +} + +#[derive(Deserialize, Serialize)] +pub struct ServerWssMessage { + message_type: ServerMessageTypes, + data: MessageData, +} + +impl ServerWssMessage { + #[must_use] + pub fn new(message_type: ServerMessageTypes, data: MessageData) -> Self { + Self { message_type, data } + } +} + +#[derive(Serialize, Deserialize)] +pub struct UserWssMessage { + message_type: UserMessageTypes, + data: MessageData, +} + +impl UserWssMessage { + #[must_use] + pub fn new(message_type: UserMessageTypes, data: MessageData) -> Self { + Self { message_type, data } + } } pub struct ShAPIServer { @@ -105,16 +142,21 @@ async fn ws_handle_socket(mut socket: WebSocket) { // deserialize the message and see if it's a request for config match msg { Message::Text(text) => { - match serde_json::from_str(&text) { - Ok(MessageRequest::RequestConfig) => { - // send the config - socket - .send(Message::Text("test".to_string())) - .await - .unwrap(); - } + let (message_type, data) = match serde_json::from_str::(&text) { + Ok(message) => (message.message_type, message.data), Err(e) => { error!("Error deserializing message: {e}"); + continue; + } + }; + + match message_type { + UserMessageTypes::UserRequestConfig => { + let response_type = ServerMessageTypes::ServerResponseConfig; + let data = MessageData::Config("test".to_string()); + let message = ServerWssMessage::new(response_type, data); + let config = serde_json::to_string(&message).unwrap(); + socket.send(Message::Text(config)).await.unwrap(); } } } @@ -122,10 +164,12 @@ async fn ws_handle_socket(mut socket: WebSocket) { error!("Binary messages not supported"); } Message::Ping(_) => { - error!("Ping messages not supported"); + // respond with a pong + log::debug!("Received ping, responding with pong"); + socket.send(Message::Pong(vec![])).await.unwrap(); } Message::Pong(_) => { - error!("Pong messages not supported"); + log::debug!("Received pong"); } Message::Close(_) => { error!("Close messages not supported"); From e733170ee08ffe30b49dad8b171cc8a9dade3f3a Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 14 May 2024 09:53:21 -0600 Subject: [PATCH 11/12] wip --- Cargo.lock | 18 +- sh-frontend/Cargo.lock | 1510 +--------------------------- sh-frontend/Cargo.toml | 5 +- sh-frontend/src/app/mod.rs | 2 +- src/bin/sh-tauri/Cargo.toml | 2 +- src/libraries/sh-api/src/lib.rs | 64 +- src/libraries/sh-common/Cargo.toml | 2 + src/libraries/sh-common/src/lib.rs | 43 + src/libraries/sh-config/Cargo.toml | 2 +- 9 files changed, 113 insertions(+), 1535 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 91354e6..0bf741b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,9 +72,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" @@ -3406,9 +3406,9 @@ dependencies = [ [[package]] name = "sdre-rust-logging" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2afae84b8b266836f049a963c74b360f93227636640f6b9926e2d1f3fc92f368" +checksum = "30b3028f94704eb1ca2606a3dff00e9bb97b82f43f13aeda1d0a50b827bc4ac0" dependencies = [ "anstyle", "chrono", @@ -3645,6 +3645,8 @@ name = "sh-common" version = "4.0.0-alpha.1" dependencies = [ "async-trait", + "serde", + "serde_json", ] [[package]] @@ -4013,9 +4015,9 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "tauri" -version = "1.6.3" +version = "1.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a4fab012dcf1e72762561cef2c08a6538aec2ca44d282158128117f79eb9d39" +checksum = "13ce04f77bcd40bb57ec7061725c9c415d30b2bf80257637b857ee067f2fa198" dependencies = [ "anyhow", "bytes", @@ -4151,9 +4153,9 @@ dependencies = [ [[package]] name = "tauri-runtime-wry" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a777eaa0d88ae47d8081cdc667eba8941b3a18af0f0ccb22640d8f0c3431d6d1" +checksum = "ef2af45aeb15b1cadb4ca91248423f4438a0864b836298cecb436892afbfdff4" dependencies = [ "arboard", "cocoa", diff --git a/sh-frontend/Cargo.lock b/sh-frontend/Cargo.lock index 8e58ab1..a919efd 100644 --- a/sh-frontend/Cargo.lock +++ b/sh-frontend/Cargo.lock @@ -17,79 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "anstream" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" - -[[package]] -name = "anstyle-parse" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" -dependencies = [ - "windows-sys 0.52.0", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" -dependencies = [ - "anstyle", - "windows-sys 0.52.0", -] - [[package]] name = "anymap2" version = "0.13.0" @@ -107,79 +34,12 @@ dependencies = [ "syn 2.0.60", ] -[[package]] -name = "atomic" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994" -dependencies = [ - "bytemuck", -] - [[package]] name = "autocfg" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" -[[package]] -name = "axum" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" -dependencies = [ - "async-trait", - "axum-core", - "base64 0.21.7", - "bytes", - "futures-util", - "http 1.1.0", - "http-body", - "http-body-util", - "hyper", - "hyper-util", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "rustversion", - "serde", - "serde_json", - "serde_path_to_error", - "serde_urlencoded", - "sha1", - "sync_wrapper 1.0.1", - "tokio", - "tokio-tungstenite", - "tower", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "axum-core" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" -dependencies = [ - "async-trait", - "bytes", - "futures-util", - "http 1.1.0", - "http-body", - "http-body-util", - "mime", - "pin-project-lite", - "rustversion", - "sync_wrapper 0.1.2", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "backtrace" version = "0.3.71" @@ -195,18 +55,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - -[[package]] -name = "base64" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" - [[package]] name = "bincode" version = "1.3.3" @@ -216,27 +64,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - [[package]] name = "boolinator" version = "2.4.0" @@ -249,18 +76,6 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" -[[package]] -name = "bytemuck" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "bytes" version = "1.6.0" @@ -279,26 +94,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "js-sys", - "num-traits", - "wasm-bindgen", - "windows-targets 0.52.5", -] - -[[package]] -name = "colorchoice" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" - [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -309,167 +104,18 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - -[[package]] -name = "cpufeatures" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "data-encoding" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", -] - -[[package]] -name = "directories" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.48.0", -] - -[[package]] -name = "encoding_rs" -version = "0.8.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "env_filter" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "humantime", - "log", -] - [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "errno" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "fastrand" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" - -[[package]] -name = "figment" -version = "0.10.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d032832d74006f99547004d49410a4b4218e4c33382d56ca3ff89df74f86b953" -dependencies = [ - "atomic", - "pear", - "serde", - "toml", - "uncased", - "version_check", -] - [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.1" @@ -568,16 +214,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - [[package]] name = "getrandom" version = "0.2.14" @@ -808,7 +444,7 @@ dependencies = [ "futures-core", "futures-sink", "gloo-utils 0.1.7", - "http 0.2.12", + "http", "js-sys", "pin-project", "serde", @@ -829,7 +465,7 @@ dependencies = [ "futures-core", "futures-sink", "gloo-utils 0.2.0", - "http 0.2.12", + "http", "js-sys", "pin-project", "serde", @@ -850,7 +486,7 @@ dependencies = [ "futures-core", "futures-sink", "gloo-utils 0.2.0", - "http 0.2.12", + "http", "js-sys", "pin-project", "serde", @@ -1026,25 +662,6 @@ dependencies = [ "syn 2.0.60", ] -[[package]] -name = "h2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 1.1.0", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "hashbrown" version = "0.14.3" @@ -1069,215 +686,59 @@ dependencies = [ ] [[package]] -name = "http" -version = "1.1.0" +name = "idna" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ - "bytes", - "fnv", - "itoa", + "unicode-bidi", + "unicode-normalization", ] [[package]] -name = "http-body" -version = "1.0.0" +name = "implicit-clone" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +checksum = "f8a9aa791c7b5a71b636b7a68207fdebf171ddfc593d9c8506ec4cbc527b6a84" dependencies = [ - "bytes", - "http 1.1.0", + "implicit-clone-derive", + "indexmap", ] [[package]] -name = "http-body-util" +name = "implicit-clone-derive" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +checksum = "9311685eb9a34808bbb0608ad2fcab9ae216266beca5848613e95553ac914e3b" dependencies = [ - "bytes", - "futures-core", - "http 1.1.0", - "http-body", - "pin-project-lite", + "quote", + "syn 2.0.60", ] [[package]] -name = "httparse" -version = "1.8.0" +name = "indexmap" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] [[package]] -name = "httpdate" -version = "1.0.3" +name = "itoa" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] -name = "humantime" -version = "2.1.0" +name = "js-sys" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "hyper" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "h2", - "http 1.1.0", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "smallvec", - "tokio", - "want", -] - -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" -dependencies = [ - "bytes", - "http-body-util", - "hyper", - "hyper-util", - "native-tls", - "tokio", - "tokio-native-tls", - "tower-service", -] - -[[package]] -name = "hyper-util" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "http 1.1.0", - "http-body", - "hyper", - "pin-project-lite", - "socket2", - "tokio", - "tower", - "tower-service", - "tracing", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "idna" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "implicit-clone" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8a9aa791c7b5a71b636b7a68207fdebf171ddfc593d9c8506ec4cbc527b6a84" -dependencies = [ - "implicit-clone-derive", - "indexmap", -] - -[[package]] -name = "implicit-clone-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9311685eb9a34808bbb0608ad2fcab9ae216266beca5848613e95553ac914e3b" -dependencies = [ - "quote", - "syn 2.0.60", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "inlinable_string" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" - -[[package]] -name = "ipnet" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" - -[[package]] -name = "is_terminal_polyfill" -version = "1.70.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "js-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] [[package]] name = "leaflet" @@ -1298,56 +759,18 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" -[[package]] -name = "libredox" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" -dependencies = [ - "bitflags 2.5.0", - "libc", -] - -[[package]] -name = "linux-raw-sys" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" - -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" -[[package]] -name = "matchit" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" - [[package]] name = "memchr" version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - [[package]] name = "miniz_oxide" version = "0.7.2" @@ -1357,44 +780,6 @@ dependencies = [ "adler", ] -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "wasi", - "windows-sys 0.48.0", -] - -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "num_cpus" version = "1.16.0" @@ -1420,108 +805,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "openssl" -version = "0.10.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" -dependencies = [ - "bitflags 2.5.0", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.60", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - -[[package]] -name = "parking_lot" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.52.5", -] - [[package]] name = "paste" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" -[[package]] -name = "pear" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdeeaa00ce488657faba8ebf44ab9361f9365a97bd39ffb8a60663f57ff4b467" -dependencies = [ - "inlinable_string", - "pear_codegen", - "yansi", -] - -[[package]] -name = "pear_codegen" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bab5b985dc082b345f812b7df84e1bef27e7207b39e448439ba8bd69c93f147" -dependencies = [ - "proc-macro2", - "proc-macro2-diagnostics", - "quote", - "syn 2.0.60", -] - [[package]] name = "percent-encoding" version = "2.3.1" @@ -1571,18 +860,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "pkg-config" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "prettyplease" version = "0.2.19" @@ -1600,7 +877,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit 0.19.15", + "toml_edit", ] [[package]] @@ -1636,19 +913,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "proc-macro2-diagnostics" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.60", - "version_check", - "yansi", -] - [[package]] name = "prokio" version = "0.1.0" @@ -1675,85 +939,6 @@ 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 = "redox_syscall" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" -dependencies = [ - "bitflags 2.5.0", -] - -[[package]] -name = "redox_users" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" -dependencies = [ - "getrandom", - "libredox", - "thiserror", -] - -[[package]] -name = "regex" -version = "1.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" - [[package]] name = "reqwasm" version = "0.5.0" @@ -1763,48 +948,6 @@ dependencies = [ "gloo-net 0.1.0", ] -[[package]] -name = "reqwest" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" -dependencies = [ - "base64 0.22.0", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http 1.1.0", - "http-body", - "http-body-util", - "hyper", - "hyper-tls", - "hyper-util", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls-pemfile", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 0.1.2", - "system-configuration", - "tokio", - "tokio-native-tls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - [[package]] name = "route-recognizer" version = "0.3.1" @@ -1817,35 +960,6 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "rustix" -version = "0.38.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3cc72858054fcff6d7dea32df2aeaee6a7c24227366d7ea429aada2f26b16ad" -dependencies = [ - "bitflags 2.5.0", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - -[[package]] -name = "rustls-pemfile" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" -dependencies = [ - "base64 0.22.0", - "rustls-pki-types", -] - -[[package]] -name = "rustls-pki-types" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" - [[package]] name = "rustversion" version = "1.0.15" @@ -1858,62 +972,12 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" -[[package]] -name = "schannel" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "scoped-tls" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "sdre-rust-logging" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b3028f94704eb1ca2606a3dff00e9bb97b82f43f13aeda1d0a50b827bc4ac0" -dependencies = [ - "anstyle", - "chrono", - "env_logger", - "log", -] - -[[package]] -name = "security-framework" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "serde" version = "1.0.201" @@ -1923,17 +987,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-inline-default" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9980133dc534d02ab08df3b384295223a45090c40a4c46240e3eaa982b495910" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.60", -] - [[package]] name = "serde-wasm-bindgen" version = "0.5.0" @@ -1978,25 +1031,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_path_to_error" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" -dependencies = [ - "itoa", - "serde", -] - -[[package]] -name = "serde_spanned" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" -dependencies = [ - "serde", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2009,39 +1043,13 @@ dependencies = [ "serde", ] -[[package]] -name = "sh-api" -version = "4.0.0-alpha.1" -dependencies = [ - "async-trait", - "axum", - "log", - "serde", - "serde_json", - "sh-common", - "sh-config", - "tokio", -] - [[package]] name = "sh-common" version = "4.0.0-alpha.1" dependencies = [ - "async-trait", -] - -[[package]] -name = "sh-config" -version = "4.0.0-alpha.1" -dependencies = [ - "directories", - "figment", - "log", - "sdre-rust-logging", + "async-trait", "serde", - "serde-inline-default", - "toml", - "void", + "serde_json", ] [[package]] @@ -2055,10 +1063,9 @@ dependencies = [ "leaflet", "log", "reqwasm", - "reqwest", "serde", "serde_json", - "sh-api", + "sh-common", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test", @@ -2069,26 +1076,6 @@ dependencies = [ "yew-router", ] -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" -dependencies = [ - "libc", -] - [[package]] name = "slab" version = "0.4.9" @@ -2098,22 +1085,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - -[[package]] -name = "socket2" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - [[package]] name = "syn" version = "1.0.109" @@ -2135,51 +1106,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[package]] -name = "sync_wrapper" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" - -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "tempfile" -version = "3.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" -dependencies = [ - "cfg-if", - "fastrand", - "rustix", - "windows-sys 0.52.0", -] - [[package]] name = "thiserror" version = "1.0.59" @@ -2222,38 +1148,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", - "bytes", - "libc", - "mio", - "num_cpus", - "parking_lot", "pin-project-lite", - "signal-hook-registry", - "socket2", - "tokio-macros", - "tracing", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-macros" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.60", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", ] [[package]] @@ -2267,52 +1162,11 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-tungstenite" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite", -] - -[[package]] -name = "tokio-util" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", - "tracing", -] - -[[package]] -name = "toml" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit 0.22.12", -] - [[package]] name = "toml_datetime" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" -dependencies = [ - "serde", -] [[package]] name = "toml_edit" @@ -2322,57 +1176,15 @@ checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap", "toml_datetime", - "winnow 0.5.40", -] - -[[package]] -name = "toml_edit" -version = "0.22.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime", - "winnow 0.6.8", -] - -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tokio", - "tower-layer", - "tower-service", - "tracing", + "winnow", ] -[[package]] -name = "tower-layer" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - [[package]] name = "tracing" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -2398,46 +1210,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - -[[package]] -name = "tungstenite" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 1.1.0", - "httparse", - "log", - "rand", - "sha1", - "thiserror", - "url", - "utf-8", -] - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "uncased" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697" -dependencies = [ - "version_check", -] - [[package]] name = "unicode-bidi" version = "0.3.15" @@ -2476,45 +1248,12 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" -[[package]] -name = "utf-8" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" - -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2635,154 +1374,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets 0.52.5", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.5", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - -[[package]] -name = "windows-targets" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" -dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", - "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" - [[package]] name = "winnow" version = "0.5.40" @@ -2792,31 +1383,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winnow" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" -dependencies = [ - "memchr", -] - -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - -[[package]] -name = "yansi" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" - [[package]] name = "yew" version = "0.21.0" diff --git a/sh-frontend/Cargo.toml b/sh-frontend/Cargo.toml index a09501a..3c29685 100644 --- a/sh-frontend/Cargo.toml +++ b/sh-frontend/Cargo.toml @@ -45,10 +45,9 @@ gloo-storage = "0.3.0" gloo-utils = "0.2.0" leaflet = "0.4.0" log = "0.4.21" -serde = "1.0.201" +serde = { version = "1.0.201", features = ["derive"] } serde_json = "1.0.117" reqwasm = "0.5.0" -reqwest = { version = "0.12.4", features = ["json"] } yew = { version = "0.21.0", features = ["csr"] } yew-router = "0.18.0" yew-hooks = "0.3.1" @@ -62,7 +61,7 @@ web-sys = { version = "0.3.69", features = [ "KeyboardEvent", ] } -sh-api = { path = "../src/libraries/sh-api" } +sh-common = { path = "../src/libraries/sh-common" } [dev-dependencies] wasm-bindgen-test = "0.3.42" diff --git a/sh-frontend/src/app/mod.rs b/sh-frontend/src/app/mod.rs index 81c37bc..f8a345f 100644 --- a/sh-frontend/src/app/mod.rs +++ b/sh-frontend/src/app/mod.rs @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -use sh_api::{MessageData, UserMessageTypes, UserWssMessage}; +use sh_common::{MessageData, UserMessageTypes, UserWssMessage}; use yew::prelude::*; use yew_router::prelude::*; diff --git a/src/bin/sh-tauri/Cargo.toml b/src/bin/sh-tauri/Cargo.toml index 2473d57..2f38c15 100644 --- a/src/bin/sh-tauri/Cargo.toml +++ b/src/bin/sh-tauri/Cargo.toml @@ -23,7 +23,7 @@ serde_json = "1.0.117" serde = { version = "1.0.201", features = ["derive"] } sdrehub = { path = "../../libraries/sdrehub" } sh-config = { path = "../../libraries/sh-config" } -tauri = { version = "1.6.3", features = ["api-all"] } +tauri = { version = "1.6.5", features = ["api-all"] } tokio = { version = "1.37.0", features = ["full", "tracing"] } [features] diff --git a/src/libraries/sh-api/src/lib.rs b/src/libraries/sh-api/src/lib.rs index 4378d4f..1ea3614 100644 --- a/src/libraries/sh-api/src/lib.rs +++ b/src/libraries/sh-api/src/lib.rs @@ -19,54 +19,14 @@ use axum::{ routing::get, Router, }; -use serde::{Deserialize, Serialize}; -use sh_common::ShDataUser; + +use sh_common::{ + MessageData, ServerMessageTypes, ServerWssMessage, ShDataUser, UserMessageTypes, UserWssMessage, +}; use sh_config::ShConfig; #[macro_use] extern crate log; -#[derive(Serialize, Deserialize)] -pub enum UserMessageTypes { - UserRequestConfig, -} - -#[derive(Serialize, Deserialize)] -pub enum ServerMessageTypes { - ServerResponseConfig, -} - -#[derive(Deserialize, Serialize)] -pub enum MessageData { - Config(String), - None, -} - -#[derive(Deserialize, Serialize)] -pub struct ServerWssMessage { - message_type: ServerMessageTypes, - data: MessageData, -} - -impl ServerWssMessage { - #[must_use] - pub fn new(message_type: ServerMessageTypes, data: MessageData) -> Self { - Self { message_type, data } - } -} - -#[derive(Serialize, Deserialize)] -pub struct UserWssMessage { - message_type: UserMessageTypes, - data: MessageData, -} - -impl UserWssMessage { - #[must_use] - pub fn new(message_type: UserMessageTypes, data: MessageData) -> Self { - Self { message_type, data } - } -} - pub struct ShAPIServer { _config: std::sync::Arc, } @@ -142,16 +102,22 @@ async fn ws_handle_socket(mut socket: WebSocket) { // deserialize the message and see if it's a request for config match msg { Message::Text(text) => { - let (message_type, data) = match serde_json::from_str::(&text) { - Ok(message) => (message.message_type, message.data), + let message: UserWssMessage = match serde_json::from_str::(&text) { + Ok(message) => message, Err(e) => { error!("Error deserializing message: {e}"); continue; } }; - match message_type { + match message.message_type { UserMessageTypes::UserRequestConfig => { + // check the data + if message.data != MessageData::None { + error!("Received UserRequestConfig message with data"); + continue; + } + let response_type = ServerMessageTypes::ServerResponseConfig; let data = MessageData::Config("test".to_string()); let message = ServerWssMessage::new(response_type, data); @@ -169,10 +135,10 @@ async fn ws_handle_socket(mut socket: WebSocket) { socket.send(Message::Pong(vec![])).await.unwrap(); } Message::Pong(_) => { - log::debug!("Received pong"); + debug!("Received pong"); } Message::Close(_) => { - error!("Close messages not supported"); + trace!("Close messages not supported"); } } } diff --git a/src/libraries/sh-common/Cargo.toml b/src/libraries/sh-common/Cargo.toml index ab6bf25..db7fafa 100644 --- a/src/libraries/sh-common/Cargo.toml +++ b/src/libraries/sh-common/Cargo.toml @@ -17,3 +17,5 @@ keywords.workspace = true [dependencies] async-trait = "0.1.80" +serde = { version = "1.0.201", features = ["derive"] } +serde_json = "1.0.117" diff --git a/src/libraries/sh-common/src/lib.rs b/src/libraries/sh-common/src/lib.rs index 285b8ef..75cb482 100644 --- a/src/libraries/sh-common/src/lib.rs +++ b/src/libraries/sh-common/src/lib.rs @@ -15,6 +15,7 @@ // This is the main loop of the SDRE Hub. use async_trait::async_trait; +use serde::{Deserialize, Serialize}; #[async_trait] pub trait ShDataUser { @@ -24,3 +25,45 @@ pub trait ShDataUser { } pub type ShDataUserList = Vec>; + +#[derive(Serialize, Deserialize)] +pub enum UserMessageTypes { + UserRequestConfig, +} + +#[derive(Serialize, Deserialize)] +pub enum ServerMessageTypes { + ServerResponseConfig, +} + +#[derive(Deserialize, Serialize, Eq, PartialEq)] +pub enum MessageData { + Config(String), + None, +} + +#[derive(Deserialize, Serialize)] +pub struct ServerWssMessage { + message_type: ServerMessageTypes, + data: MessageData, +} + +impl ServerWssMessage { + #[must_use] + pub fn new(message_type: ServerMessageTypes, data: MessageData) -> Self { + Self { message_type, data } + } +} + +#[derive(Serialize, Deserialize)] +pub struct UserWssMessage { + pub message_type: UserMessageTypes, + pub data: MessageData, +} + +impl UserWssMessage { + #[must_use] + pub fn new(message_type: UserMessageTypes, data: MessageData) -> Self { + Self { message_type, data } + } +} diff --git a/src/libraries/sh-config/Cargo.toml b/src/libraries/sh-config/Cargo.toml index f3e71dc..05b228c 100644 --- a/src/libraries/sh-config/Cargo.toml +++ b/src/libraries/sh-config/Cargo.toml @@ -17,7 +17,7 @@ keywords.workspace = true [dependencies] figment = { version = "0.10.18", features = ["toml", "env"] } -sdre-rust-logging = "0.3.1" +sdre-rust-logging = "0.3.2" log = "0.4.21" serde = { version = "1.0.201", features = ["derive"] } serde-inline-default = "0.2.0" From d9c4d7b46a138db4d3ebce56cbf25f8cd69c3ea6 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 14 May 2024 12:36:59 -0600 Subject: [PATCH 12/12] wip ws send data bidirectional --- Cargo.lock | 1 + sh-frontend/Cargo.lock | 583 +++++++++++++++++- sh-frontend/src/app/mod.rs | 4 +- src/libraries/sdrehub/src/lib.rs | 45 +- src/libraries/sh-api/src/lib.rs | 69 ++- src/libraries/sh-common/Cargo.toml | 1 + src/libraries/sh-common/src/lib.rs | 18 +- .../sh-config/src/acars_router_source.rs | 2 +- src/libraries/sh-config/src/address.rs | 4 +- src/libraries/sh-config/src/adsb_source.rs | 2 +- src/libraries/sh-config/src/lib.rs | 2 +- src/libraries/sh-config/src/map.rs | 2 +- src/libraries/sh-config/src/sdrehub.rs | 2 +- src/libraries/sh-config/src/source.rs | 6 +- 14 files changed, 699 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0bf741b..c5c6178 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3647,6 +3647,7 @@ dependencies = [ "async-trait", "serde", "serde_json", + "sh-config", ] [[package]] diff --git a/sh-frontend/Cargo.lock b/sh-frontend/Cargo.lock index a919efd..4d5d6ef 100644 --- a/sh-frontend/Cargo.lock +++ b/sh-frontend/Cargo.lock @@ -17,6 +17,79 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" + +[[package]] +name = "anstyle-parse" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anymap2" version = "0.13.0" @@ -34,6 +107,15 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "atomic" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994" +dependencies = [ + "bytemuck", +] + [[package]] name = "autocfg" version = "1.2.0" @@ -64,6 +146,12 @@ dependencies = [ "serde", ] +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + [[package]] name = "boolinator" version = "2.4.0" @@ -76,6 +164,12 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "bytemuck" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" + [[package]] name = "bytes" version = "1.6.0" @@ -94,6 +188,26 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets 0.52.5", +] + +[[package]] +name = "colorchoice" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -104,12 +218,76 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "directories" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", +] + [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "figment" +version = "0.10.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d032832d74006f99547004d49410a4b4218e4c33382d56ca3ff89df74f86b953" +dependencies = [ + "atomic", + "pear", + "serde", + "toml", + "uncased", + "version_check", +] + [[package]] name = "fnv" version = "1.0.7" @@ -685,6 +863,35 @@ dependencies = [ "itoa", ] +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "idna" version = "0.5.0" @@ -725,6 +932,18 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "inlinable_string" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itoa" version = "1.0.11" @@ -759,6 +978,16 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags", + "libc", +] + [[package]] name = "log" version = "0.4.21" @@ -780,6 +1009,15 @@ dependencies = [ "adler", ] +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -805,12 +1043,41 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "paste" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "pear" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdeeaa00ce488657faba8ebf44ab9361f9365a97bd39ffb8a60663f57ff4b467" +dependencies = [ + "inlinable_string", + "pear_codegen", + "yansi", +] + +[[package]] +name = "pear_codegen" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bab5b985dc082b345f812b7df84e1bef27e7207b39e448439ba8bd69c93f147" +dependencies = [ + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn 2.0.60", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -877,7 +1144,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", ] [[package]] @@ -913,6 +1180,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", + "version_check", + "yansi", +] + [[package]] name = "prokio" version = "0.1.0" @@ -939,6 +1219,46 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "redox_users" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + [[package]] name = "reqwasm" version = "0.5.0" @@ -978,6 +1298,18 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +[[package]] +name = "sdre-rust-logging" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b3028f94704eb1ca2606a3dff00e9bb97b82f43f13aeda1d0a50b827bc4ac0" +dependencies = [ + "anstyle", + "chrono", + "env_logger", + "log", +] + [[package]] name = "serde" version = "1.0.201" @@ -987,6 +1319,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-inline-default" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9980133dc534d02ab08df3b384295223a45090c40a4c46240e3eaa982b495910" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "serde-wasm-bindgen" version = "0.5.0" @@ -1031,6 +1374,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1050,6 +1402,21 @@ dependencies = [ "async-trait", "serde", "serde_json", + "sh-config", +] + +[[package]] +name = "sh-config" +version = "4.0.0-alpha.1" +dependencies = [ + "directories", + "figment", + "log", + "sdre-rust-logging", + "serde", + "serde-inline-default", + "toml", + "void", ] [[package]] @@ -1162,11 +1529,26 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.12", +] + [[package]] name = "toml_datetime" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -1176,7 +1558,20 @@ checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap", "toml_datetime", - "winnow", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.6.8", ] [[package]] @@ -1210,6 +1605,15 @@ dependencies = [ "once_cell", ] +[[package]] +name = "uncased" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.15" @@ -1248,12 +1652,24 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1374,6 +1790,154 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + [[package]] name = "winnow" version = "0.5.40" @@ -1383,6 +1947,21 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +dependencies = [ + "memchr", +] + +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + [[package]] name = "yew" version = "0.21.0" diff --git a/sh-frontend/src/app/mod.rs b/sh-frontend/src/app/mod.rs index f8a345f..db08cb8 100644 --- a/sh-frontend/src/app/mod.rs +++ b/sh-frontend/src/app/mod.rs @@ -33,7 +33,7 @@ pub fn switch(routes: ShAppRoute) -> Html { } pub struct App { - wss: WebsocketService, + _wss: WebsocketService, } impl Component for App { @@ -57,7 +57,7 @@ impl Component for App { } } - Self { wss } + Self { _wss: wss } } fn update(&mut self, _ctx: &Context, _msg: Self::Message) -> bool { diff --git a/src/libraries/sdrehub/src/lib.rs b/src/libraries/sdrehub/src/lib.rs index a2c1003..219b5da 100644 --- a/src/libraries/sdrehub/src/lib.rs +++ b/src/libraries/sdrehub/src/lib.rs @@ -25,13 +25,15 @@ #[macro_use] extern crate log; +use std::sync::{Arc, Mutex}; + use sh_api::ShAPIServer; -use sh_common::ShDataUserList; +use sh_common::{ServerType, ShDataUserList}; use sh_config::ShConfig; use tokio::task::JoinSet; pub struct SdreHub { - config: std::sync::Arc, + config: std::sync::Arc>, data_users: ShDataUserList, } @@ -39,7 +41,7 @@ impl SdreHub { #[must_use] pub fn new(config: ShConfig) -> Self { Self { - config: std::sync::Arc::new(config), + config: std::sync::Arc::new(Mutex::new(config)), data_users: Vec::new(), } } @@ -47,24 +49,49 @@ impl SdreHub { /// # Errors /// - Error starting consumer: {e} pub async fn run(mut self) -> Result<(), Box> { + // get the config lock + let config_lock = Arc::clone(&self.config); + let config = match config_lock.lock() { + Ok(c) => c.clone(), + Err(e) => { + error!("Error getting config lock: {e}"); + return Err(Box::new(std::io::Error::new( + std::io::ErrorKind::Other, + "Error getting config lock", + ))); + } + }; + // init logging and stuff - self.config.enable_logging(); - self.config.write_config(); - self.config.show_config(); + config.enable_logging(); + config.write_config(); + config.show_config(); + + // release the lock + drop(config_lock); + // Start the web server let mut consumer_set = JoinSet::new(); // lets generate the consumers - self.data_users - .push(Box::new(ShAPIServer::new(self.config.clone()))); + self.data_users.push(Box::new(ShAPIServer::new())); debug!("Starting consumers"); for fut in self.data_users { + // if the kind of ShDataUser is ShAPIServer, then we can spawn it + let config = match fut.get_server_type() { + ServerType::WebSocket => { + // Start the web server + Some(Arc::clone(&self.config)) + } + ServerType::Other => None, + }; + consumer_set.spawn(tokio::spawn(async move { - match fut.start().await { + match fut.start(config).await { Ok(()) => {} Err(e) => { error!("Error starting consumer: {e}"); diff --git a/src/libraries/sh-api/src/lib.rs b/src/libraries/sh-api/src/lib.rs index 1ea3614..5028a37 100644 --- a/src/libraries/sh-api/src/lib.rs +++ b/src/libraries/sh-api/src/lib.rs @@ -12,30 +12,48 @@ clippy::all )] +use std::sync::{Arc, Mutex}; + use async_trait::async_trait; use axum::{ - extract::ws::{Message, WebSocket, WebSocketUpgrade}, + extract::{ + ws::{Message, WebSocket, WebSocketUpgrade}, + State, + }, response::Response, routing::get, Router, }; use sh_common::{ - MessageData, ServerMessageTypes, ServerWssMessage, ShDataUser, UserMessageTypes, UserWssMessage, + MessageData, ServerMessageTypes, ServerType, ServerWssMessage, ShDataUser, UserMessageTypes, + UserWssMessage, }; use sh_config::ShConfig; #[macro_use] extern crate log; -pub struct ShAPIServer { - _config: std::sync::Arc, +pub struct ShAPIServer {} + +struct ShAPIServerState { + config: Arc>, } #[async_trait] impl ShDataUser for ShAPIServer { - async fn start(&self) -> Result<(), Box> { + async fn start( + &self, + data: Option>>, + ) -> Result<(), Box> { // Start the web server - self.run_apiserver().await + let Some(config) = data else { + error!("No configuration provided to start the API server"); + return Err(Box::new(std::io::Error::new( + std::io::ErrorKind::Other, + "No configuration provided to start the API server", + ))); + }; + self.run_apiserver(config).await } // TODO: Can we dynamically start/stop/restart the web server? @@ -46,17 +64,30 @@ impl ShDataUser for ShAPIServer { fn restart(&self) { // Restart the web server } + + fn get_server_type(&self) -> sh_common::ServerType { + ServerType::WebSocket + } +} + +impl Default for ShAPIServer { + fn default() -> Self { + Self::new() + } } impl ShAPIServer { #[must_use] - pub fn new(config: std::sync::Arc) -> Self { - Self { _config: config } + pub const fn new() -> Self { + Self {} } /// # Errors /// - Error binding socket for websocket server: {e} - pub async fn run_apiserver(&self) -> Result<(), Box> { + pub async fn run_apiserver( + &self, + config: Arc>, + ) -> Result<(), Box> { let listener = match tokio::net::TcpListener::bind("0.0.0.0:3000").await { Ok(listener) => listener, Err(e) => { @@ -73,8 +104,10 @@ impl ShAPIServer { } }; + let server = Arc::new(ShAPIServerState { config }); + info!("listening for websocket connections on {}", local_addr); - if axum::serve(listener, app()).await.is_err() { + if axum::serve(listener, app(server)).await.is_err() { error!("Error starting WebSocket server"); return Err(Box::new(std::io::Error::new( std::io::ErrorKind::Other, @@ -86,18 +119,20 @@ impl ShAPIServer { } } -fn app() -> Router { +fn app(server: Arc) -> Router { debug!("Starting WebSocket server"); - Router::new().route("/sdre-hub", get(ws_handler)) + Router::new() + .route("/sdre-hub", get(ws_handler)) + .with_state(server) } -async fn ws_handler(ws: WebSocketUpgrade) -> Response { +async fn ws_handler(ws: WebSocketUpgrade, State(server): State>) -> Response { debug!("WebSocket connection initiated"); - ws.on_upgrade(ws_handle_socket) + ws.on_upgrade(|socket| ws_handle_socket(socket, server)) } -async fn ws_handle_socket(mut socket: WebSocket) { +async fn ws_handle_socket(mut socket: WebSocket, state: Arc) { while let Some(Ok(msg)) = socket.recv().await { // deserialize the message and see if it's a request for config match msg { @@ -119,7 +154,9 @@ async fn ws_handle_socket(mut socket: WebSocket) { } let response_type = ServerMessageTypes::ServerResponseConfig; - let data = MessageData::Config("test".to_string()); + // get the server config + let config = state.config.lock().unwrap().clone(); + let data = MessageData::Config(config); let message = ServerWssMessage::new(response_type, data); let config = serde_json::to_string(&message).unwrap(); socket.send(Message::Text(config)).await.unwrap(); diff --git a/src/libraries/sh-common/Cargo.toml b/src/libraries/sh-common/Cargo.toml index db7fafa..79ca9f7 100644 --- a/src/libraries/sh-common/Cargo.toml +++ b/src/libraries/sh-common/Cargo.toml @@ -19,3 +19,4 @@ keywords.workspace = true async-trait = "0.1.80" serde = { version = "1.0.201", features = ["derive"] } serde_json = "1.0.117" +sh-config = { path = "../sh-config" } diff --git a/src/libraries/sh-common/src/lib.rs b/src/libraries/sh-common/src/lib.rs index 75cb482..25b33cd 100644 --- a/src/libraries/sh-common/src/lib.rs +++ b/src/libraries/sh-common/src/lib.rs @@ -14,14 +14,21 @@ // This is the main loop of the SDRE Hub. +use std::sync::{Arc, Mutex}; + use async_trait::async_trait; use serde::{Deserialize, Serialize}; +use sh_config::ShConfig; #[async_trait] pub trait ShDataUser { - async fn start(&self) -> Result<(), Box>; + async fn start( + &self, + data: Option>>, + ) -> Result<(), Box>; fn stop(&self); fn restart(&self); + fn get_server_type(&self) -> ServerType; } pub type ShDataUserList = Vec>; @@ -36,9 +43,9 @@ pub enum ServerMessageTypes { ServerResponseConfig, } -#[derive(Deserialize, Serialize, Eq, PartialEq)] +#[derive(Deserialize, Serialize, PartialEq)] pub enum MessageData { - Config(String), + Config(ShConfig), None, } @@ -67,3 +74,8 @@ impl UserWssMessage { Self { message_type, data } } } + +pub enum ServerType { + WebSocket, + Other, +} diff --git a/src/libraries/sh-config/src/acars_router_source.rs b/src/libraries/sh-config/src/acars_router_source.rs index 11e1257..c4b4f0a 100644 --- a/src/libraries/sh-config/src/acars_router_source.rs +++ b/src/libraries/sh-config/src/acars_router_source.rs @@ -17,7 +17,7 @@ pub trait SourceTrait { fn new() -> Self; fn insert(&mut self, value: ShAcarsRouterConfig); } -#[derive(Debug, Serialize, Deserialize, Default)] +#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Eq, Clone)] pub struct AcarsRouterSource { addresses: Vec, } diff --git a/src/libraries/sh-config/src/address.rs b/src/libraries/sh-config/src/address.rs index d160c14..b61e7ac 100644 --- a/src/libraries/sh-config/src/address.rs +++ b/src/libraries/sh-config/src/address.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; /// Struct to store the address of an ACARS router -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)] pub struct ShAcarsRouterConfig { address: String, port: u32, @@ -41,7 +41,7 @@ impl ShAcarsRouterConfig { } } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)] pub struct SHAdsbConfig { address: String, port: u32, diff --git a/src/libraries/sh-config/src/adsb_source.rs b/src/libraries/sh-config/src/adsb_source.rs index 74583da..f7d30cc 100644 --- a/src/libraries/sh-config/src/adsb_source.rs +++ b/src/libraries/sh-config/src/adsb_source.rs @@ -18,7 +18,7 @@ pub trait SourceTrait { fn insert(&mut self, value: SHAdsbConfig); } -#[derive(Debug, Serialize, Deserialize, Default)] +#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Clone)] pub struct AdsbSource { addresses: Vec, } diff --git a/src/libraries/sh-config/src/lib.rs b/src/libraries/sh-config/src/lib.rs index c1dc093..34dd006 100644 --- a/src/libraries/sh-config/src/lib.rs +++ b/src/libraries/sh-config/src/lib.rs @@ -38,7 +38,7 @@ pub mod source; // FIXME: env variables require a dot between the prefix and the variable name. This is not ideal. Should be able to use underscores #[serde_inline_default] -#[derive(Debug, Serialize, Deserialize, Default)] +#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Clone)] pub struct ShConfig { #[serde_inline_default(SDREHub::default())] pub app: SDREHub, diff --git a/src/libraries/sh-config/src/map.rs b/src/libraries/sh-config/src/map.rs index b82b80b..7c14527 100644 --- a/src/libraries/sh-config/src/map.rs +++ b/src/libraries/sh-config/src/map.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; /// `MapConfig` is a struct for storing global map values -#[derive(Debug, Serialize, Deserialize, Default)] +#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Clone)] pub struct ShMapConfig { /// `center_latitude` is the latitude of the center of the map /// This value will be used to center the map on the web interface diff --git a/src/libraries/sh-config/src/sdrehub.rs b/src/libraries/sh-config/src/sdrehub.rs index 55f298a..0fc21b1 100644 --- a/src/libraries/sh-config/src/sdrehub.rs +++ b/src/libraries/sh-config/src/sdrehub.rs @@ -9,7 +9,7 @@ use serde_inline_default::serde_inline_default; use crate::ShConfig; #[serde_inline_default] -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)] pub struct SDREHub { #[serde_inline_default("sqlite://sdre-hub.db".to_string())] pub database_url: String, diff --git a/src/libraries/sh-config/src/source.rs b/src/libraries/sh-config/src/source.rs index d958b83..ca0b7f2 100644 --- a/src/libraries/sh-config/src/source.rs +++ b/src/libraries/sh-config/src/source.rs @@ -8,7 +8,7 @@ use serde_inline_default::serde_inline_default; use crate::{acars_router_source::AcarsRouterSource, adsb_source::AdsbSource}; -#[derive(Debug, Deserialize, Default)] +#[derive(Debug, Deserialize, Default, PartialEq, Eq, Clone)] #[serde(rename_all = "snake_case", try_from = "String")] pub enum ShEnabledDataSources { Acars, @@ -55,13 +55,13 @@ impl Serialize for ShEnabledDataSources { } } -#[derive(Debug, Serialize, Deserialize, Default)] +#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Eq, Clone)] pub struct EnabledDataSources { pub enabled_sources: Vec, } #[serde_inline_default] -#[derive(Debug, Serialize, Default, Deserialize)] +#[derive(Debug, Serialize, Default, Deserialize, PartialEq, Clone)] pub struct DataSources { #[serde_inline_default(AcarsRouterSource::default())] #[serde(deserialize_with = "crate::acars_router_source::string_or_struct")]