Skip to main content

iot_core/
lib.rs

1//! # iot-core
2//!
3//! Foundation crate for the `iot-protocols` SDK. Defines the data model
4//! that every protocol implementation in the workspace agrees on:
5//!
6//! - [`thing`] — Eclipse-Ditto-style `Thing` / `Feature` / `Value` digital twin.
7//! - [`path`] — `PropertyPath`, the protocol-agnostic address of a single value.
8//! - [`binding`] — `ProtocolBinding` / `ThingMapping`, the bridge that maps a
9//!   `PropertyPath` onto a Modbus register, an MQTT topic, a CoAP URI, or an
10//!   OPC UA NodeId.
11//! - [`error`] — the unified [`error::IotError`] every public API returns.
12//! - [`client`] — the [`client::IotClient`] async trait every protocol crate
13//!   implements alongside its native API.
14//!
15//! ## Feature flags
16//!
17//! | Feature   | Adds                                    | Default |
18//! |-----------|-----------------------------------------|:-------:|
19//! | `std`     | `std::error::Error` impls, hashing      | ✓       |
20//! | `alloc`   | `Thing`, `Vec`, dynamic `BTreeMap` maps | ✓       |
21//! | `serde`   | `serde::{Serialize,Deserialize}` derives|         |
22//! | `validate`| JSON-Schema validation of `Thing`       |         |
23//!
24//! With only `alloc` (no `std`) every public type continues to work, which is
25//! the configuration MCU targets compile.
26
27#![cfg_attr(not(feature = "std"), no_std)]
28#![warn(missing_docs)]
29#![warn(rust_2018_idioms)]
30#![forbid(unsafe_code)]
31
32#[cfg(feature = "alloc")]
33extern crate alloc;
34
35pub mod binding;
36pub mod client;
37pub mod error;
38pub mod path;
39pub mod thing;
40pub mod value;
41
42#[cfg(feature = "validate")]
43pub mod schema;
44
45// Convenience re-exports — keeps user-facing imports terse.
46pub use binding::{
47    ByteOrder, ContentFormat, DataType, PayloadCodec, ProtocolBinding, Qos, RegisterArea,
48    ThingMapping,
49};
50pub use client::IotClient;
51pub use client::PropertySample;
52pub use error::{CodecError, IotError, IotResult, TransportError};
53pub use path::PropertyPath;
54pub use thing::{DefinitionIdentifier, Feature, FeatureId, PolicyId, PropertyId, Thing, ThingId};
55pub use value::Value;