Skip to main content

ethtool/pause/
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 EthtoolPauseGetRequest {
9    handle: EthtoolHandle,
10    iface_name: Option<String>,
11}
12
13impl EthtoolPauseGetRequest {
14    pub(crate) fn new(handle: EthtoolHandle, iface_name: Option<&str>) -> Self {
15        EthtoolPauseGetRequest {
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 EthtoolPauseGetRequest {
26            mut handle,
27            iface_name,
28        } = self;
29
30        let ethtool_msg = EthtoolMessage::new_pause_get(iface_name.as_deref());
31        ethtool_execute(&mut handle, iface_name.is_none(), ethtool_msg).await
32    }
33}