openthread/ot/types/
router_info.rs1use crate::prelude_internal::*;
6
7#[derive(Default, Clone)]
9#[repr(transparent)]
10pub struct RouterInfo(pub otRouterInfo);
11
12impl_ot_castable!(RouterInfo, otRouterInfo);
13
14impl RouterInfo {
15 pub fn empty() -> RouterInfo {
17 Self::default()
18 }
19}
20
21impl std::fmt::Debug for RouterInfo {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 let mut ds = f.debug_struct("RouterInfo");
24
25 ds.field("ext_address", &self.get_ext_address());
26 ds.field("rloc16", &self.get_rloc16());
27 ds.field("router_id", &self.get_router_id());
28 ds.field("next_hop", &self.get_next_hop());
29 ds.field("path_cost", &self.get_path_cost());
30 ds.field("link_quality_in", &self.get_link_quality_in());
31 ds.field("link_quality_out", &self.get_link_quality_out());
32 ds.field("age", &self.get_age());
33 ds.field("allocated", &self.get_allocated());
34 ds.field("link_established", &self.get_link_established());
35
36 ds.finish()
37 }
38}
39
40impl RouterInfo {
41 pub fn get_ext_address(&self) -> ExtAddress {
43 self.0.mExtAddress.into()
44 }
45
46 pub fn get_rloc16(&self) -> u16 {
48 self.0.mRloc16
49 }
50
51 pub fn get_router_id(&self) -> u8 {
53 self.0.mRouterId
54 }
55
56 pub fn get_next_hop(&self) -> u8 {
58 self.0.mNextHop
59 }
60
61 pub fn get_path_cost(&self) -> u8 {
63 self.0.mPathCost
64 }
65
66 pub fn get_link_quality_in(&self) -> u8 {
68 self.0.mLinkQualityIn
69 }
70
71 pub fn get_link_quality_out(&self) -> u8 {
73 self.0.mLinkQualityOut
74 }
75
76 pub fn get_age(&self) -> u8 {
78 self.0.mAge
79 }
80
81 pub fn get_allocated(&self) -> bool {
83 self.0.mAllocated()
84 }
85
86 pub fn get_link_established(&self) -> bool {
88 self.0.mLinkEstablished()
89 }
90}