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
223 downloads per month
675KB
61 lines
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
viacrossbeam-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