Skip to main content

ethtool/channel/
get.rs

1// SPDX-License-Identifier: MIT
2
3use futures::TryStream;
4use netlink_packet_generic::GenlMessage;
5
6use crate::{ethtool_execute, EthtoolError, EthtoolHandle, EthtoolMessage};
7
8pub struct EthtoolChannelGetRequest {
9    handle: EthtoolHandle,
10    iface_name: Option<String>,
11}
12
13impl EthtoolChannelGetRequest {
14    pub(crate) fn new(handle: EthtoolHandle, iface_name: Option<&str>) -> Self {
15        EthtoolChannelGetRequest {
16            handle,
17            iface_name: iface_name.map(|i| i.to_string()),
18        }
19    }
20
21    pub async fn execute(
22        self,
23    ) -> impl TryStream<Ok = GenlMessage<EthtoolMessage>, Error = EthtoolError>
24    {
25        let EthtoolChannelGetRequest {
26            mut handle,
27            iface_name,
28        } = self;
29
30        let ethtool_msg =
31            EthtoolMessage::new_channel_get(iface_name.as_deref());
32        ethtool_execute(&mut handle, iface_name.is_none(), ethtool_msg).await
33    }
34}