blob: 2cc27d56251f6ee05eea78d213d4b29a380ba579 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
use crate::Result;
use rtnetlink::Handle;
#[derive(Debug)]
pub struct Connection(Handle);
impl Connection {
/// Creates a new connection and handle to rtnetlink and spawns the connection task.
/// Can be used to interact with rtnetlink by enabling certain crate features
/// and calling the methods they provide.
pub async fn new() -> Result<Self> {
let (conn, handle, _) = rtnetlink::new_connection()?;
tokio::spawn(conn);
Ok(Self(handle))
}
/// Returns a reference to the underlying [`rtnetlink::Handle`].
pub(crate) fn handle(&self) -> &Handle {
&self.0
}
}
|