openthread/ot/types/mle_counters.rs
1// Copyright 2026 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::prelude_internal::*;
6
7/// This structure represents the MLE layer counters.
8///
9/// Functional equivalent of [`otsys::otMleCounters`](crate::otsys::otMleCounters).
10#[derive(Debug, Default, Clone)]
11#[repr(transparent)]
12pub struct MleCounters(pub otMleCounters);
13
14impl_ot_castable!(MleCounters, otMleCounters);
15
16impl MleCounters {
17 /// Number of times device entered OT_DEVICE_ROLE_DISABLED role.
18 pub fn disabled_role(&self) -> u16 {
19 self.0.mDisabledRole
20 }
21
22 /// Number of times device entered OT_DEVICE_ROLE_DETACHED role.
23 pub fn detached_role(&self) -> u16 {
24 self.0.mDetachedRole
25 }
26
27 /// Number of times device entered OT_DEVICE_ROLE_CHILD role.
28 pub fn child_role(&self) -> u16 {
29 self.0.mChildRole
30 }
31
32 /// Number of times device entered OT_DEVICE_ROLE_ROUTER role.
33 pub fn router_role(&self) -> u16 {
34 self.0.mRouterRole
35 }
36
37 /// Number of times device entered OT_DEVICE_ROLE_LEADER role.
38 pub fn leader_role(&self) -> u16 {
39 self.0.mLeaderRole
40 }
41
42 /// Number of attach attempts while device was detached.
43 pub fn attach_attempts(&self) -> u16 {
44 self.0.mAttachAttempts
45 }
46
47 /// Number of changes to partition ID.
48 pub fn partition_id_changes(&self) -> u16 {
49 self.0.mPartitionIdChanges
50 }
51
52 /// Number of attempts to attach to a better partition.
53 pub fn better_partition_attach_attempts(&self) -> u16 {
54 self.0.mBetterPartitionAttachAttempts
55 }
56
57 /// Number of attempts to attach to find a better parent (parent search).
58 pub fn better_parent_attach_attempts(&self) -> u16 {
59 self.0.mBetterParentAttachAttempts
60 }
61
62 /// Number of milliseconds device has been in OT_DEVICE_ROLE_DISABLED role.
63 pub fn disabled_time(&self) -> u64 {
64 self.0.mDisabledTime
65 }
66
67 /// Number of milliseconds device has been in OT_DEVICE_ROLE_DETACHED role.
68 pub fn detached_time(&self) -> u64 {
69 self.0.mDetachedTime
70 }
71
72 /// Number of milliseconds device has been in OT_DEVICE_ROLE_CHILD role.
73 pub fn child_time(&self) -> u64 {
74 self.0.mChildTime
75 }
76
77 /// Number of milliseconds device has been in OT_DEVICE_ROLE_ROUTER role.
78 pub fn router_time(&self) -> u64 {
79 self.0.mRouterTime
80 }
81
82 /// Number of milliseconds device has been in OT_DEVICE_ROLE_LEADER role.
83 pub fn leader_time(&self) -> u64 {
84 self.0.mLeaderTime
85 }
86
87 /// Number of milliseconds tracked by previous counters.
88 pub fn tracked_time(&self) -> u64 {
89 self.0.mTrackedTime
90 }
91
92 /// Number of times device changed its parent.
93 pub fn parent_changes(&self) -> u16 {
94 self.0.mParentChanges
95 }
96}