boomerang_runtime/
lib.rs

1#![doc=include_str!( "../README.md")]
2//! ## Feature flags
3#![doc = document_features::document_features!()]
4#![deny(clippy::all)]
5
6mod action;
7mod context;
8mod env;
9mod event;
10pub mod keepalive;
11mod key_set;
12mod partition;
13mod port;
14mod reaction;
15mod reactor;
16mod sched;
17mod store;
18mod time;
19
20// Re-exports
21pub use action::*;
22pub use context::*;
23pub use env::*;
24pub use key_set::KeySetLimits as ReactionSetLimits;
25pub use partition::{partition, partition_mut, Partition, PartitionMut};
26pub use port::*;
27pub use reaction::*;
28pub use reactor::*;
29pub use sched::*;
30pub use time::*;
31
32pub use std::time::{Duration, Instant};
33
34pub trait PortData: std::fmt::Debug + Send + Sync + 'static {}
35impl<T> PortData for T where T: std::fmt::Debug + Send + Sync + 'static {}
36
37#[derive(thiserror::Error, Debug)]
38pub enum RuntimeError {
39    #[error("Port Key not found: {}", 0)]
40    PortKeyNotFound(PortKey),
41
42    #[error("Mismatched Dynamic Types found {found} but wanted {wanted}")]
43    TypeMismatch {
44        found: &'static str,
45        wanted: &'static str,
46    },
47
48    #[cfg(feature = "serde")]
49    #[error("Serialization error: {0}")]
50    SerializationError(#[from] serde_arrow::Error),
51
52    #[error("Destructuring error")]
53    DestrError,
54}
55
56pub mod fmt_utils {
57    //! Utility functions for formatting until [debug_closure_helpers](https://github.com/rust-lang/rust/issues/117729) lands in stable.
58    pub fn from_fn<F: Fn(&mut std::fmt::Formatter<'_>) -> std::fmt::Result>(f: F) -> FromFn<F> {
59        FromFn(f)
60    }
61
62    pub struct FromFn<F>(F)
63    where
64        F: Fn(&mut std::fmt::Formatter<'_>) -> std::fmt::Result;
65
66    impl<F> std::fmt::Debug for FromFn<F>
67    where
68        F: Fn(&mut std::fmt::Formatter<'_>) -> std::fmt::Result,
69    {
70        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
71            (self.0)(f)
72        }
73    }
74}