#egui #network-connectivity #status #desktop #networking #connectivity

bin+lib yo_netwatch

A reactive network status monitor for egui apps. Inspired by Flutter's connectivity_plus, built with Rust by Yo (Yogi).

4 releases

Uses new Rust 2024

new 0.1.3 May 21, 2025
0.1.2 May 21, 2025
0.1.1 May 21, 2025
0.1.0 May 21, 2025

#7 in #connectivity

Download history 223/week @ 2025-05-16

223 downloads per month

MIT license

675KB
61 lines

yo_netwatch

yo_netwatch

📡 A reactive internet connection status checker for egui apps — inspired by Flutter's connectivity_plus, built with ❤️ in Rust by Yo.

Features

  • Detects online/offline status via TcpStream ping
  • Emits status only on state changes (not polling UI)
  • Works with egui via crossbeam-channel
  • Suitable for desktop apps with eframe

Installation

Add to your Cargo.toml:

yo_netwatch = "0.1"

Short Usage

use yo_netwatch::start_network_watcher;

let rx = start_network_watcher();
if let Ok(online) = rx.recv() {
    println!("Status jaringan: {}", if online { "Online ✅" } else { "Offline ❌" });
}

Usage

use eframe::egui;
use yo_netwatch::{start_network_watcher, Receiver};

fn main() -> Result<(), eframe::Error> {
    eframe::run_native(
        "Network Status App",
        eframe::NativeOptions::default(),
        Box::new(|_| Box::new(MyApp::new())),
    )
}

struct MyApp {
    connected: bool,
    rx: Receiver<bool>,
}

impl MyApp {
    fn new() -> Self {
        let rx = start_network_watcher();
        Self {
            connected: false,
            rx,
        }
    }
}

impl eframe::App for MyApp {
    fn update(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {
        while let Ok(status) = self.rx.try_recv() {
            self.connected = status;
        }

        egui::CentralPanel::default().show(ctx, |ui| {
            ui.heading("📡 Internet Status:");
            ui.label(if self.connected {
                "✅ Online"
            } else {
                "❌ Offline"
            });
        });

        ctx.request_repaint_after(std::time::Duration::from_millis(100));
    }
}

License

Dependencies

~7–26MB
~437K SLoC