openthread/ot/
link_metrics.rsuse crate::prelude_internal::*;
pub trait LinkMetrics {
fn link_metrics_manager_is_enabled(&self) -> bool;
fn link_metrics_manager_set_enabled(&self, enabled: bool);
fn link_metrics_manager_get_metrics_value_by_ext_addr(
&self,
ext_addr: &ExtAddress,
) -> Result<LinkMetricsValues>;
}
impl<T: LinkMetrics + ot::Boxable> LinkMetrics for ot::Box<T> {
fn link_metrics_manager_is_enabled(&self) -> bool {
self.as_ref().link_metrics_manager_is_enabled()
}
fn link_metrics_manager_set_enabled(&self, enabled: bool) {
self.as_ref().link_metrics_manager_set_enabled(enabled)
}
fn link_metrics_manager_get_metrics_value_by_ext_addr(
&self,
ext_addr: &ExtAddress,
) -> Result<LinkMetricsValues> {
self.as_ref().link_metrics_manager_get_metrics_value_by_ext_addr(ext_addr)
}
}
impl LinkMetrics for Instance {
fn link_metrics_manager_is_enabled(&self) -> bool {
unsafe { otLinkMetricsManagerIsEnabled(self.as_ot_ptr()) }
}
fn link_metrics_manager_set_enabled(&self, enabled: bool) {
unsafe { otLinkMetricsManagerSetEnabled(self.as_ot_ptr(), enabled) }
}
fn link_metrics_manager_get_metrics_value_by_ext_addr(
&self,
ext_addr: &ExtAddress,
) -> Result<LinkMetricsValues> {
let mut values = LinkMetricsValues::default();
Error::from(unsafe {
otLinkMetricsManagerGetMetricsValueByExtAddr(
self.as_ot_ptr(),
ext_addr.as_ot_ptr(),
values.as_ot_mut_ptr(),
)
})
.into_result()?;
Ok(values)
}
}