From 5eae79df038e577b901e7c2c43c4b95de1d0e4eb Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 8 Aug 2025 15:56:20 +0200 Subject: [PATCH] commit at why2025 --- src/config.rs | 11 +++++++++++ src/main.rs | 14 ++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/config.rs b/src/config.rs index 11dea2c..ce34fdd 100644 --- a/src/config.rs +++ b/src/config.rs @@ -27,6 +27,17 @@ pub struct Config { } impl Config { + pub fn init() -> Self { + let mut c = Config { + pseudo: Some("".into()), + channel: Some("".into()), + set_theme: Some(false), + enc: Some(false), + enc_key: Some("".into()), + }; + c.load(); + c + } pub fn new(pseudo: &str, channel: &str, set_theme: bool, enc: bool, enc_key: &str) -> Self { Config { pseudo: Some(pseudo.to_string()), diff --git a/src/main.rs b/src/main.rs index b2290d0..33950c6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,20 +13,22 @@ use tokio::runtime::Runtime; use tokio::sync::mpsc::*; use tokio::sync::*; -fn main() { - let mut cfg: Config = Config::new("", "", false, false, ""); - cfg.load(); +const DEFAULT_CHAN_SIZE: usize = 10; +fn main() { + let cfg = Config::init(); let mut c = window::new_window(); - let (app_to_net_s, app_to_net_r): (Sender>, Receiver>) = channel(10); - let (net_to_app_s, net_to_app_r): (Sender>, Receiver>) = channel(10); + let (app_to_net_s, app_to_net_r): (Sender>, Receiver>) = + channel(DEFAULT_CHAN_SIZE); + let (net_to_app_s, net_to_app_r): (Sender>, Receiver>) = + channel(DEFAULT_CHAN_SIZE); let net_to_app_r = Arc::new(RwLock::new(net_to_app_r)); let net_to_app_s = Arc::new(RwLock::new(net_to_app_s)); let app_to_net_r = Arc::new(RwLock::new(app_to_net_r)); - let ctx: Context = Context::new(cfg, app_to_net_s); + let ctx = Context::new(cfg, app_to_net_s); let window_ctx = Arc::new(RwLock::new(ctx)); let wctx_window = Arc::clone(&window_ctx);