1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#![doc = include_str!("../README.md")]
#![deny(clippy::pedantic)]
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::missing_panics_doc)]
#![allow(clippy::missing_safety_doc)]

pub mod ip;
pub mod link;
pub mod route;

/// Get a handle on a new rtnetlink connection
#[cfg(feature = "tokio")]
pub fn new_handle() -> Result<rtnetlink::Handle, std::io::Error> {
    let (rt_connection, rt_handle, _) = rtnetlink::new_connection().map_err(|err| {
        log::error!("Failed to open rtnetlink connection");
        log::error!("{}", err);
        err
    })?;
    tokio::spawn(rt_connection);
    Ok(rt_handle)
}