From 01cd02c0f95b8c6b60c4937bbca493f92e961969 Mon Sep 17 00:00:00 2001 From: shadow cat Date: Tue, 18 Nov 2025 02:38:23 -0500 Subject: [PATCH] more refactor --- Cargo.toml | 8 +++++++ src/bin/{openworm-client => client}/app.rs | 0 .../assets/sungals.png | Bin src/bin/{openworm-client => client}/input.rs | 0 src/bin/{openworm-client => client}/main.rs | 20 ++++++++++++------ src/bin/{openworm-client => client}/net.rs | 0 .../{openworm-client => client}/render/mod.rs | 0 src/bin/client/rsc.rs | 16 ++++++++++++++ src/bin/{openworm-client => client}/ui.rs | 0 src/net/no_cert.rs | 2 ++ src/rsc.rs | 17 --------------- 11 files changed, 39 insertions(+), 24 deletions(-) rename src/bin/{openworm-client => client}/app.rs (100%) rename src/bin/{openworm-client => client}/assets/sungals.png (100%) rename src/bin/{openworm-client => client}/input.rs (100%) rename src/bin/{openworm-client => client}/main.rs (98%) rename src/bin/{openworm-client => client}/net.rs (100%) rename src/bin/{openworm-client => client}/render/mod.rs (100%) create mode 100644 src/bin/client/rsc.rs rename src/bin/{openworm-client => client}/ui.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 367654e..7d6a425 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,3 +18,11 @@ winit = "0.30.12" bincode = "2.0.1" zstd = "0.13.3" ron = "0.12.0" + +[[bin]] +name = "openworm-client" +path = "src/bin/client/main.rs" + +[[bin]] +name = "openworm-server" +path = "src/bin/server/main.rs" diff --git a/src/bin/openworm-client/app.rs b/src/bin/client/app.rs similarity index 100% rename from src/bin/openworm-client/app.rs rename to src/bin/client/app.rs diff --git a/src/bin/openworm-client/assets/sungals.png b/src/bin/client/assets/sungals.png similarity index 100% rename from src/bin/openworm-client/assets/sungals.png rename to src/bin/client/assets/sungals.png diff --git a/src/bin/openworm-client/input.rs b/src/bin/client/input.rs similarity index 100% rename from src/bin/openworm-client/input.rs rename to src/bin/client/input.rs diff --git a/src/bin/openworm-client/main.rs b/src/bin/client/main.rs similarity index 98% rename from src/bin/openworm-client/main.rs rename to src/bin/client/main.rs index ac16155..c5b67d9 100644 --- a/src/bin/openworm-client/main.rs +++ b/src/bin/client/main.rs @@ -1,13 +1,18 @@ #![windows_subsystem = "windows"] -use crate::{app::App, net::NetSender, ui::*}; +use crate::{ + app::App, + net::NetSender, + rsc::{CLIENT_DATA, ClientData}, + ui::*, +}; pub use app::AppHandle; use arboard::Clipboard; use input::Input; use iris::prelude::*; use openworm::{ net::{ClientMsg, ServerMsg, install_crypto_provider}, - rsc::{CLIENT_DATA, ClientData, DataDir}, + rsc::DataDir, }; use render::Renderer; use std::sync::Arc; @@ -17,17 +22,18 @@ use winit::{ window::Window, }; -fn main() { - install_crypto_provider(); - App::run(); -} - mod app; mod input; mod net; mod render; +mod rsc; mod ui; +fn main() { + install_crypto_provider(); + App::run(); +} + pub enum ClientEvent { Connect { send: NetSender, username: String }, ServerMsg(ServerMsg), diff --git a/src/bin/openworm-client/net.rs b/src/bin/client/net.rs similarity index 100% rename from src/bin/openworm-client/net.rs rename to src/bin/client/net.rs diff --git a/src/bin/openworm-client/render/mod.rs b/src/bin/client/render/mod.rs similarity index 100% rename from src/bin/openworm-client/render/mod.rs rename to src/bin/client/render/mod.rs diff --git a/src/bin/client/rsc.rs b/src/bin/client/rsc.rs new file mode 100644 index 0000000..cd5e91d --- /dev/null +++ b/src/bin/client/rsc.rs @@ -0,0 +1,16 @@ +pub const CLIENT_DATA: &str = "client_data"; + +#[derive(bincode::Encode, bincode::Decode)] +pub struct ClientData { + pub ip: String, + pub username: String, +} + +impl Default for ClientData { + fn default() -> Self { + Self { + ip: "localhost:39420".to_string(), + username: "your [NOVEMBER]".to_string(), + } + } +} diff --git a/src/bin/openworm-client/ui.rs b/src/bin/client/ui.rs similarity index 100% rename from src/bin/openworm-client/ui.rs rename to src/bin/client/ui.rs diff --git a/src/net/no_cert.rs b/src/net/no_cert.rs index df83323..f235f16 100644 --- a/src/net/no_cert.rs +++ b/src/net/no_cert.rs @@ -1,3 +1,5 @@ +// stolen default impl from example + use quinn::rustls::{self, pki_types::*}; use std::sync::Arc; diff --git a/src/rsc.rs b/src/rsc.rs index 91ccd31..4e68087 100644 --- a/src/rsc.rs +++ b/src/rsc.rs @@ -7,8 +7,6 @@ use directories_next::ProjectDirs; use crate::net::BINCODE_CONFIG; -pub const CLIENT_DATA: &str = "client_data"; - pub struct DataDir { dirs: ProjectDirs, } @@ -44,18 +42,3 @@ impl DataDir { bincode::encode_into_std_write(data, &mut file, BINCODE_CONFIG).unwrap(); } } - -#[derive(bincode::Encode, bincode::Decode)] -pub struct ClientData { - pub ip: String, - pub username: String, -} - -impl Default for ClientData { - fn default() -> Self { - Self { - ip: "localhost:39420".to_string(), - username: "your [NOVEMBER]".to_string(), - } - } -}