#[cfg(feature = "std")]
pub use self::std_types::*;
pub use self::{direction::Direction, utils::*};
pub mod direction;
pub type BoxAny = Box<dyn core::any::Any>;
pub type Result<T = ()> = core::result::Result<T, crate::errors::Error>;
#[cfg(feature = "std")]
mod std_types {
use std::sync::{Arc, Mutex};
pub type AsyncError = Box<dyn std::error::Error + Send + Sync>;
pub type AsyncResult<T = ()> = core::result::Result<T, AsyncError>;
pub type BoxError = Box<dyn std::error::Error>;
pub type BoxResult<T = (), E = BoxError> = core::result::Result<T, E>;
pub type Locked<T> = Arc<Mutex<T>>;
pub type IOResult<T = ()> = std::io::Result<T>;
}
pub(crate) mod utils {
use core::any::{Any, TypeId};
use core::str::FromStr;
pub fn is_string<T: ?Sized + Any>(_s: &T) -> bool {
TypeId::of::<String>() == TypeId::of::<T>()
}
pub fn is_float<T>(_val: &T) -> bool
where
T: Any + ?Sized,
{
TypeId::of::<f64>() == TypeId::of::<T>()
}
pub fn is_str_float<T: ToString>(data: &T) -> bool {
f64::from_str(&data.to_string()).is_ok()
}
}
pub(crate) mod prelude {
pub use super::direction::Direction;
#[cfg(feature = "std")]
pub use super::std_types::*;
pub use super::utils::*;
pub use super::{BoxAny, Result};
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_is_string() {
let s = "hello";
assert!(!is_string(&s));
assert!(is_string(&s.to_string()))
}
}