Skip to main content

openthread/ot/types/
lowpan_context_info.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
7use core::fmt::{Debug, Formatter};
8
9/// Data type representing 6LoWPAN Context ID information associated with a prefix in Network Data.
10/// Functional equivalent of [`otsys::otLowpanContextInfo`](crate::otsys::otLowpanContextInfo).
11#[derive(Default, Clone)]
12#[repr(transparent)]
13pub struct LowpanContextInfo(pub otLowpanContextInfo);
14
15impl_ot_castable!(LowpanContextInfo, otLowpanContextInfo);
16
17impl Debug for LowpanContextInfo {
18    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
19        f.debug_struct("LowpanContextInfo")
20            .field("compress_flag", &self.compress_flag())
21            .field("context_id", &self.context_id())
22            .field("prefix", &self.prefix())
23            .field("is_stable", &self.is_stable())
24            .finish()
25    }
26}
27
28impl LowpanContextInfo {
29    /// Returns the compress flag.
30    pub fn compress_flag(&self) -> bool {
31        self.0.mCompressFlag()
32    }
33
34    /// Returns the 6LoWPAN Context ID.
35    pub fn context_id(&self) -> u8 {
36        self.0.mContextId
37    }
38
39    /// Returns the associated IPv6 prefix.
40    pub fn prefix(&self) -> &Ip6Prefix {
41        (&self.0.mPrefix).into()
42    }
43
44    /// Whether the Context TLV is marked as Stable Network Data.
45    pub fn is_stable(&self) -> bool {
46        self.0.mStable()
47    }
48}