sentinel_core/utils/
mod.rs

1use std::any::Any;
2use std::sync::Arc;
3
4pub mod time;
5
6pub use self::time::*;
7
8pub fn is_blank(path: &String) -> bool {
9    path.trim().len() == 0
10}
11
12/// not a general implememtation,
13/// only used in our `core::flow::WarmUpCalculator`,
14/// which won't overflow as long as parameter in rule is rational
15pub(crate) fn next_after(x: f64) -> f64 {
16    let x = x.to_bits();
17    let x = if (x >> 63) == 0 { x + 1 } else { x - 1 };
18    f64::from_bits(x)
19}
20
21/// Trait for upcast/downcast
22pub trait AsAny: Any + Send + Sync {
23    fn as_any(&self) -> &(dyn Any + Send + Sync);
24    fn as_any_arc(self: Arc<Self>) -> Arc<dyn Any + Send + Sync>;
25}
26
27// impl the required AsAny trait for structs
28impl<T: Any + Send + Sync> AsAny for T {
29    fn as_any(&self) -> &(dyn Any + Send + Sync) {
30        self
31    }
32
33    fn as_any_arc(self: Arc<Self>) -> Arc<dyn Any + Send + Sync> {
34        self
35    }
36}