openthread/ot/
link_metrics.rs1use crate::prelude_internal::*;
6
7pub trait LinkMetrics {
11 fn link_metrics_manager_is_enabled(&self) -> bool;
13
14 fn link_metrics_manager_set_enabled(&self, enabled: bool);
16
17 fn link_metrics_manager_get_metrics_value_by_ext_addr(
19 &self,
20 ext_addr: &ExtAddress,
21 ) -> Result<LinkMetricsValues>;
22}
23
24impl<T: LinkMetrics + ot::Boxable> LinkMetrics for ot::Box<T> {
25 fn link_metrics_manager_is_enabled(&self) -> bool {
26 self.as_ref().link_metrics_manager_is_enabled()
27 }
28
29 fn link_metrics_manager_set_enabled(&self, enabled: bool) {
30 self.as_ref().link_metrics_manager_set_enabled(enabled)
31 }
32
33 fn link_metrics_manager_get_metrics_value_by_ext_addr(
34 &self,
35 ext_addr: &ExtAddress,
36 ) -> Result<LinkMetricsValues> {
37 self.as_ref().link_metrics_manager_get_metrics_value_by_ext_addr(ext_addr)
38 }
39}
40
41impl LinkMetrics for Instance {
42 fn link_metrics_manager_is_enabled(&self) -> bool {
43 unsafe { otLinkMetricsManagerIsEnabled(self.as_ot_ptr()) }
44 }
45
46 fn link_metrics_manager_set_enabled(&self, enabled: bool) {
47 unsafe { otLinkMetricsManagerSetEnabled(self.as_ot_ptr(), enabled) }
48 }
49
50 fn link_metrics_manager_get_metrics_value_by_ext_addr(
51 &self,
52 ext_addr: &ExtAddress,
53 ) -> Result<LinkMetricsValues> {
54 let mut values = LinkMetricsValues::default();
55 Error::from(unsafe {
56 otLinkMetricsManagerGetMetricsValueByExtAddr(
57 self.as_ot_ptr(),
58 ext_addr.as_ot_ptr(),
59 values.as_ot_mut_ptr(),
60 )
61 })
62 .into_result()?;
63 Ok(values)
64 }
65}