rtlola_interpreter/
lib.rs

1//! # The RTLola Interpreter
2//! The RTLola interpreter is a library used to evaluate RTLola specifications.
3//! It is designed such that it easily integrates into your setup through highly configurable APIs.
4//!
5//! ## Features
6//! - `queued-api` (Default): By default the library features a queued API that uses threads. If your target architecture doesn't support threads, consider disabling this feature through "default-features = false"
7//! - `serde`: Enables Serde Serialization and Deserialization support for API interface structs.
8//!
9//! ## Usage
10//! The main entrypoint of the application is the [ConfigBuilder].
11//! It features multiple methods to configure the interpreter for your needs.
12//! From there you can create a [Monitor] or [QueuedMonitor].
13//! The main interaction points of the library.
14
15#![forbid(unused_must_use)] // disallow discarding errors
16#![warn(
17    missing_docs,
18    missing_debug_implementations,
19    missing_copy_implementations,
20    trivial_casts,
21    trivial_numeric_casts,
22    unsafe_code,
23    unstable_features,
24    unused_import_braces,
25    unused_qualifications
26)]
27
28// Public exports
29use std::time::Duration;
30
31// Reexport itertools helper for macros
32pub use itertools::izip;
33// Reexport Frontend
34pub use rtlola_frontend;
35pub use rtlola_frontend::mir as rtlola_mir;
36
37pub use crate::api::input::ValueGetter;
38// Serialize and Deserialize traits for serde support
39pub use crate::api::monitor;
40pub use crate::api::monitor::Monitor;
41#[cfg(feature = "queued-api")]
42pub use crate::api::queued;
43#[cfg(feature = "queued-api")]
44pub use crate::api::queued::QueuedMonitor;
45pub use crate::api::{input, output};
46pub use crate::configuration::config_builder::ConfigBuilder;
47pub use crate::configuration::{config, time};
48pub use crate::storage::{Value, ValueConvertError};
49
50mod api;
51mod closuregen;
52mod configuration;
53mod evaluator;
54mod schedule;
55mod storage;
56#[cfg(test)]
57mod tests;
58
59/// The internal time representation.
60pub type Time = Duration;
61
62#[cfg(feature = "serde")]
63use serde::{Deserialize, Serialize};
64
65/// A helper trait to conditionally require a `serde::Serialize` as a trait bound when the `serde` feature is activated.
66#[cfg(feature = "serde")]
67pub trait CondSerialize: Serialize {}
68
69#[cfg(not(feature = "serde"))]
70/// A helper trait to conditionally require a `serde::Serialize` as a trait bound when the `serde` feature is activated.
71pub trait CondSerialize {}
72
73#[cfg(feature = "serde")]
74impl<T: Serialize> CondSerialize for T {}
75#[cfg(not(feature = "serde"))]
76impl<T> CondSerialize for T {}
77
78#[cfg(feature = "serde")]
79/// A helper trait to conditionally require a `serde::Deserialize` as a trait bound when the `serde` feature is activated.
80pub trait CondDeserialize: for<'a> Deserialize<'a> {}
81
82#[cfg(not(feature = "serde"))]
83/// A helper trait to conditionally require a `serde::Deserialize` as a trait bound when the `serde` feature is activated.
84pub trait CondDeserialize {}
85
86#[cfg(feature = "serde")]
87impl<T: for<'a> Deserialize<'a>> CondDeserialize for T {}
88#[cfg(not(feature = "serde"))]
89impl<T> CondDeserialize for T {}