#cross-platform #networking #routes #ip

route_manager

Cross-platform route management interface

15 releases

new 0.2.11 Jan 14, 2026
0.2.10 Jan 6, 2026
0.2.9 Aug 12, 2025
0.2.5 Jul 31, 2025
0.1.3 Mar 7, 2025

#291 in Network programming

Download history 2071/week @ 2025-09-29 2056/week @ 2025-10-06 2419/week @ 2025-10-13 1624/week @ 2025-10-20 934/week @ 2025-10-27 1560/week @ 2025-11-03 1838/week @ 2025-11-10 1594/week @ 2025-11-17 1385/week @ 2025-11-24 2468/week @ 2025-12-01 1674/week @ 2025-12-08 2023/week @ 2025-12-15 849/week @ 2025-12-22 1333/week @ 2025-12-29 1614/week @ 2026-01-05 1963/week @ 2026-01-12

5,794 downloads per month
Used in 15 crates (3 directly)

Apache-2.0

1MB
27K SLoC

route_manager

Crates.io 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
OpenBSD
NetBSD

Features:

  1. Supporting Synchronous and Asynchronous API
  2. Supports choosing between Tokio and async-io for asynchronous I/O operations.

Example:

Asynchronous API

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;
}

Synchronous API

use route_manager::{Route, RouteManager};
use std::thread;
use std::time::Duration;

pub fn main() {
    let mut route_listener = RouteManager::listener().unwrap();
    #[cfg(feature = "shutdown")]
    let shutdown_handle = route_listener.shutdown_handle().unwrap();
    thread::spawn(move || {
        while let Ok(route) = route_listener.listen() {
            println!("listen {route}");
        }
        println!("========= end =========");
    });
    // 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 = RouteManager::new().unwrap();

    let result = manager.add(&route);
    println!("route add {route} {result:?}");
    thread::sleep(Duration::from_secs(1));
    let result = manager.delete(&route);
    println!("route delete {route} {result:?}");
    thread::sleep(Duration::from_secs(1));
    #[cfg(feature = "shutdown")]
    shutdown_handle.shutdown().unwrap();
    thread::sleep(Duration::from_secs(100));
}

Reference project

Dependencies

~0–14MB
~145K SLoC