Skip to main content

moddef_core/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! ModDef runtime for Rust (spec v0.4).
4//!
5//! Layering (spec ยง32):
6//! - **codec core** (always available, `no_std`, no alloc): [`desc::PointDesc`]
7//!   descriptors + [`codec`] decode/encode + [`Transport`] trait + errors.
8//! - **`alloc`**: prost schema types ([`schema`]), owned [`value::DecodedValue`],
9//!   the untyped [`device::Device`] facade, measurand queries, binary `.moddef`
10//!   parsing.
11//! - **`std`** (default): protojson YAML/JSON parsing ([`document`]), fs
12//!   helpers, `std::error::Error` impls.
13//!
14//! Embedded targets use generated `static` descriptor tables (see
15//! `moddef-codegen`) and never parse documents at runtime; servers/gateways
16//! parse `.moddef` files at runtime and use the dynamic facade. Both paths
17//! share this codec.
18#![cfg_attr(not(feature = "std"), no_std)]
19#![deny(unsafe_code)]
20
21#[cfg(feature = "alloc")]
22extern crate alloc;
23
24pub mod codec;
25pub mod desc;
26pub mod error;
27pub mod rt;
28pub mod transport;
29pub mod value;
30
31#[cfg(feature = "alloc")]
32pub mod schema;
33
34#[cfg(feature = "alloc")]
35pub mod convert;
36
37#[cfg(feature = "alloc")]
38pub mod command;
39
40#[cfg(feature = "alloc")]
41pub mod device;
42
43#[cfg(feature = "alloc")]
44pub mod measurand;
45
46#[cfg(feature = "std")]
47pub mod document;
48
49#[cfg(feature = "std")]
50pub mod resolve;
51
52pub use desc::{
53    Access, AddressSpace, ComposedSub, DateTimeEncoding, FieldDesc, NaDesc, PointDesc, Rational,
54    ScaleMode, ScaleRefDesc, SelectorCaseDesc, SelectorDesc, StorageType, StringPadding,
55    StringTermination, ValueKind, WriteDesc,
56};
57pub use error::{ConstraintKind, DecodeError, EncodeError, Error};
58pub use transport::Transport;
59pub use value::{Reading, Value};
60
61#[cfg(feature = "alloc")]
62pub use command::{condition_met, Delay, ParamValue};
63#[cfg(feature = "alloc")]
64pub use device::Device;
65#[cfg(feature = "alloc")]
66pub use measurand::MeasurandQuery;
67#[cfg(feature = "alloc")]
68pub use value::DecodedValue;
69
70#[cfg(feature = "std")]
71pub use document::{
72    detect_format, load, parse_document, serialize_document, DocumentFormat, ParseError,
73};