-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconnection.rs
34 lines (29 loc) · 921 Bytes
/
connection.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: MIT
use std::io;
use futures::channel::mpsc::UnboundedReceiver;
use genetlink::message::RawGenlMessage;
use netlink_packet_core::NetlinkMessage;
use netlink_proto::Connection;
use netlink_sys::{AsyncSocket, SocketAddr};
use crate::EthtoolHandle;
#[cfg(feature = "tokio_socket")]
#[allow(clippy::type_complexity)]
pub fn new_connection() -> io::Result<(
Connection<RawGenlMessage>,
EthtoolHandle,
UnboundedReceiver<(NetlinkMessage<RawGenlMessage>, SocketAddr)>,
)> {
new_connection_with_socket()
}
#[allow(clippy::type_complexity)]
pub fn new_connection_with_socket<S>() -> io::Result<(
Connection<RawGenlMessage, S>,
EthtoolHandle,
UnboundedReceiver<(NetlinkMessage<RawGenlMessage>, SocketAddr)>,
)>
where
S: AsyncSocket,
{
let (conn, handle, messages) = genetlink::new_connection_with_socket()?;
Ok((conn, EthtoolHandle::new(handle), messages))
}