openthread/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

//! This crate contains a type-safe interface to the OpenThread API.
//!
//! This crate assumes that the OpenThread platform interface have been
//! provided externally, perhaps by a separate crate.

#![warn(missing_docs)]
#![warn(missing_debug_implementations)]
#![warn(rust_2018_idioms)]

pub mod ot;
pub use openthread_sys as otsys;

#[cfg(target_os = "fuchsia")]
mod otfuchsia;

/// Shorthand for `ot::Box<T>`
pub type OtBox<T> = ot::Box<T>;

/// Shorthand for `ot::Box<ot::Instance>`.
pub type OtInstanceBox = ot::Box<ot::Instance>;

/// Shorthand for `ot::Box<ot::Message<'a>>`.
pub type OtMessageBox<'a> = ot::Box<ot::Message<'a>>;

/// Prelude namespace for improving the ergonomics of using this crate.
#[macro_use]
pub mod prelude {
    #![allow(unused_imports)]

    pub use crate::{ot, otsys, OtBox, OtInstanceBox, OtMessageBox};
    pub use ot::{
        BackboneRouter as _, BorderRouter as _, Boxable as _, Dnssd as _, DnssdExt as _,
        IntoOtError as _, Ip6 as _, Link as _, MessageBuffer as _, OtCastable as _, Reset as _,
        SrpServer as _, State as _, Tasklets as _, Thread as _, Udp as _, Uptime as _,
    };

    pub use ot::TaskletsStreamExt as _;
    pub use std::convert::{TryFrom as _, TryInto as _};
}

// Internal prelude namespace for internal crate use only.
#[doc(hidden)]
#[macro_use]
pub(crate) mod prelude_internal {
    #![allow(unused_imports)]

    pub use crate::impl_ot_castable;
    pub use crate::otsys::*;
    pub use crate::prelude::*;
    pub use core::convert::{TryFrom, TryInto};
    pub use futures::prelude::*;
    pub use num::FromPrimitive as _;
    pub(crate) use ot::ascii_dump;
    pub use ot::types::*;
    pub use ot::{
        BackboneRouter, BorderRouter, Boxable, Error, Instance, InstanceInterface, Ip6, Link,
        Message, MessageBuffer, Platform, Result, SrpServer, Tasklets, Thread,
    };
    pub use static_assertions as sa;
    pub use std::ffi::{CStr, CString};
    pub use std::marker::PhantomData;
    pub use std::os::raw::c_char;
    pub use std::ptr::null;
    pub use tracing::{debug, error, info, trace, warn};
}