use crate::macros::GenlTypedDumpStream;
use crate::netlink::{connection::Connection, error::Result};
use super::messages::{
NetShaperCapsGetRequest, NetShaperCapsReply, NetShaperDeleteRequest, NetShaperGetRequest,
NetShaperHandle, NetShaperReply, NetShaperSetRequest,
};
use super::types::NetShaperScope;
use super::NetShaper;
impl Connection<NetShaper> {
pub async fn get_shaper(
&self,
ifindex: u32,
handle: NetShaperHandle,
) -> Result<NetShaperReply> {
self.send_typed(NetShaperGetRequest::by_handle(ifindex, handle))
.await
}
pub async fn dump_shapers(
&self,
ifindex: u32,
) -> Result<GenlTypedDumpStream<'_, NetShaper, NetShaperReply>> {
self.dump_typed_stream(NetShaperGetRequest::dump(ifindex))
.await
}
pub async fn set_shaper(&self, req: NetShaperSetRequest) -> Result<()> {
let _: NetShaperReply = self.send_typed(req).await?;
Ok(())
}
pub async fn del_shaper(&self, ifindex: u32, handle: NetShaperHandle) -> Result<()> {
let _: NetShaperReply = self
.send_typed(NetShaperDeleteRequest::new(ifindex, handle))
.await?;
Ok(())
}
pub async fn get_caps(
&self,
ifindex: u32,
scope: NetShaperScope,
) -> Result<NetShaperCapsReply> {
self.send_typed(NetShaperCapsGetRequest::for_scope(ifindex, scope))
.await
}
pub async fn dump_caps(
&self,
ifindex: u32,
) -> Result<GenlTypedDumpStream<'_, NetShaper, NetShaperCapsReply>> {
self.dump_typed_stream(NetShaperCapsGetRequest::dump(ifindex))
.await
}
}