pub use self::utils::*;
use std::sync::{Arc, Mutex};
pub type AnyAsync = Box<dyn std::any::Any + Send + Sync + 'static>;
pub type AsyncError = Box<dyn std::error::Error + Send + Sync>;
pub type AsyncResult<T = ()> = std::result::Result<T, AsyncError>;
pub type BoxError = Box<dyn std::error::Error>;
pub type BoxResult<T = (), E = BoxError> = std::result::Result<T, E>;
pub type Locked<T> = Arc<Mutex<T>>;
pub type IOResult<T = ()> = std::io::Result<T>;
pub type Result<T = ()> = std::result::Result<T, crate::errors::Error>;
pub(crate) mod utils {
use std::any::{Any, TypeId};
use std::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()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_is_string() {
let s = "hello";
assert!(!is_string(&s));
assert!(is_string(&s.to_string()))
}
}