4 releases
new 0.1.3 | Mar 7, 2025 |
---|---|
0.1.2 | Mar 5, 2025 |
0.1.1 | Mar 5, 2025 |
0.1.0 | Mar 5, 2025 |
#1398 in Network programming
418 downloads per month
81KB
2K
SLoC
route_manager
Used for adding, deleting, and querying routes, with support for asynchronous or synchronous monitoring of route changes.
Supported Platforms
Platform | |
---|---|
Windows | ✅ |
Linux | ✅ |
macOS | ✅ |
FreeBSD | ✅ |
Features:
- Supporting Synchronous and Asynchronous API
- Supports choosing between Tokio and async-io for asynchronous I/O operations.
Example:
use route_manager::{AsyncRouteManager, Route};
use std::time::Duration;
#[tokio::main]
pub async fn main() {
let mut route_listener = AsyncRouteManager::listener().unwrap();
tokio::spawn(async move {
while let Ok(route) = route_listener.listen().await {
println!("listen {route}");
}
});
// Need to set up the correct gateway
let route = Route::new("192.168.2.0".parse().unwrap(), 24).with_if_index(1);
let mut manager = AsyncRouteManager::new().unwrap();
let result = manager.add(&route).await;
println!("route add {route} {result:?}");
tokio::time::sleep(Duration::from_secs(1)).await;
let result = manager.delete(&route).await;
println!("route delete {route} {result:?}");
tokio::time::sleep(Duration::from_secs(1)).await;
}
Reference project
Dependencies
~0.4–14MB
~202K SLoC