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 device;
39
40#[cfg(feature = "alloc")]
41pub mod measurand;
42
43#[cfg(feature = "std")]
44pub mod document;
45
46#[cfg(feature = "std")]
47pub mod resolve;
48
49pub use desc::{
50    Access, AddressSpace, DateTimeEncoding, FieldDesc, NaDesc, PointDesc, Rational, ScaleMode,
51    ScaleRefDesc, SelectorCaseDesc, SelectorDesc, StorageType, StringPadding, StringTermination,
52    ValueKind, WriteDesc,
53};
54pub use error::{ConstraintKind, DecodeError, EncodeError, Error};
55pub use transport::Transport;
56pub use value::{Reading, Value};
57
58#[cfg(feature = "alloc")]
59pub use device::Device;
60#[cfg(feature = "alloc")]
61pub use measurand::MeasurandQuery;
62#[cfg(feature = "alloc")]
63pub use value::DecodedValue;
64
65#[cfg(feature = "std")]
66pub use document::{
67    detect_format, load, parse_document, serialize_document, DocumentFormat, ParseError,
68};