use std::sync::OnceLock;
pub fn get_runtime() -> &'static tokio::runtime::Runtime {
static RUNTIME: OnceLock<tokio::runtime::Runtime> = OnceLock::new();
RUNTIME.get_or_init(|| {
tokio::runtime::Runtime::new().expect("Failed to create Tokio runtime")
})
}
pub fn to_rhai_err(msg: impl AsRef<str>) -> Box<rhai::EvalAltResult> {
Box::new(rhai::EvalAltResult::ErrorSystem(
msg.as_ref().to_string(),
Box::new(std::io::Error::new(
std::io::ErrorKind::Other,
msg.as_ref(),
)),
))
}