#cross-platform #routes #ip

route_manager

Cross-platform route management interface

15 releases

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

#306 in Network programming

Download history 871/week @ 2025-12-24 1307/week @ 2025-12-31 1899/week @ 2026-01-07 1902/week @ 2026-01-14 1388/week @ 2026-01-21 2013/week @ 2026-01-28 2087/week @ 2026-02-04 1614/week @ 2026-02-11 1972/week @ 2026-02-18 1967/week @ 2026-02-25 3481/week @ 2026-03-04 4351/week @ 2026-03-11 4499/week @ 2026-03-18 4148/week @ 2026-03-25 2277/week @ 2026-04-01 3610/week @ 2026-04-08

15,681 downloads per month
Used in 17 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–6.5MB
~142K SLoC