use crate::macros::GenlTypedDumpStream;
use crate::netlink::{
connection::Connection,
error::Result,
genl::dpll::messages::{
DpllDeviceGetRequest, DpllDeviceReply, DpllDeviceSetRequest, DpllPinGetRequest,
DpllPinReply, DpllPinSetRequest,
},
genl::dpll::types::{DpllFeatureState, DpllMode, DpllPinDirection, DpllPinState},
};
use super::Dpll;
impl Connection<Dpll> {
pub async fn get_device(&self, id: u32) -> Result<DpllDeviceReply> {
self.send_typed(DpllDeviceGetRequest::by_id(id)).await
}
pub async fn dump_devices(
&self,
) -> Result<GenlTypedDumpStream<'_, Dpll, DpllDeviceReply>> {
self.dump_typed_stream(DpllDeviceGetRequest::dump()).await
}
pub async fn set_device_mode(&self, id: u32, mode: DpllMode) -> Result<()> {
let _: DpllDeviceReply = self
.send_typed(DpllDeviceSetRequest::new(id).mode(mode))
.await?;
Ok(())
}
pub async fn set_device_phase_offset_monitor(
&self,
id: u32,
state: DpllFeatureState,
) -> Result<()> {
let _: DpllDeviceReply = self
.send_typed(DpllDeviceSetRequest::new(id).phase_offset_monitor(state))
.await?;
Ok(())
}
pub async fn set_device_frequency_monitor(
&self,
id: u32,
state: DpllFeatureState,
) -> Result<()> {
let _: DpllDeviceReply = self
.send_typed(DpllDeviceSetRequest::new(id).frequency_monitor(state))
.await?;
Ok(())
}
pub async fn get_pin(&self, id: u32) -> Result<DpllPinReply> {
self.send_typed(DpllPinGetRequest::by_id(id)).await
}
pub async fn dump_pins(
&self,
) -> Result<GenlTypedDumpStream<'_, Dpll, DpllPinReply>> {
self.dump_typed_stream(DpllPinGetRequest::dump()).await
}
pub async fn set_pin_priority(&self, id: u32, priority: u32) -> Result<()> {
let _: DpllPinReply = self
.send_typed(DpllPinSetRequest::new(id).prio(priority))
.await?;
Ok(())
}
pub async fn set_pin_state(&self, id: u32, state: DpllPinState) -> Result<()> {
let _: DpllPinReply = self
.send_typed(DpllPinSetRequest::new(id).state(state))
.await?;
Ok(())
}
pub async fn set_pin_frequency(&self, id: u32, hz: u64) -> Result<()> {
let _: DpllPinReply = self
.send_typed(DpllPinSetRequest::new(id).frequency(hz))
.await?;
Ok(())
}
pub async fn set_pin_direction(
&self,
id: u32,
direction: DpllPinDirection,
) -> Result<()> {
let _: DpllPinReply = self
.send_typed(DpllPinSetRequest::new(id).direction(direction))
.await?;
Ok(())
}
}