srad_eon/lib.rs
1//! Part of [srad](https://crates.io/crates/srad), a general purpose [Sparkplug](https://sparkplug.eclipse.org/) development library in rust.
2//!
3//! This library defines a framework for implementing Sparkplug Edge of Network Nodes.
4//!
5//! # Overview
6//!
7//! `srad-eon` provides a general implementation of a Sparkplug Node.
8//!
9//! The implementation requires the provision of [MetricManager] implementations to the node or when registering devices. This allows for
10//! defining metrics which belong to the node or device as well as the custom handling of CMD messages for those metrics.
11//!
12//! The node starts a tokio `task` for itself node and each subsequent device.
13//! These tasks are used to process incoming state changes and messages from sparkplug topics such as CMD messages
14
15mod birth;
16mod builder;
17mod device;
18mod metric;
19mod metric_manager;
20mod node;
21use thiserror::Error;
22
23pub use birth::{BirthInitializer, BirthMetricDetails};
24pub use builder::EoNBuilder;
25pub use device::DeviceHandle;
26pub use metric::*;
27pub use metric_manager::manager::{
28 DeviceMetricManager, MetricManager, NoMetricManager, NodeMetricManager,
29};
30pub use metric_manager::simple_manager;
31pub use node::{EoN, NodeHandle, TemplateRegistry};
32
33#[derive(Debug, PartialEq, Clone, Copy)]
34pub(crate) enum BirthType {
35 Birth,
36 Rebirth,
37}
38
39#[derive(Debug, Error)]
40pub enum StateError {
41 #[error("Connection state is Offline")]
42 Offline,
43 #[error("The node or device is not birthed.")]
44 UnBirthed,
45}