use tokio::runtime::Runtime;
#[inline]
pub fn cstring_sanitized(input: &'static str) -> ::std::ffi::CString {
let bytes = input.as_bytes();
let mut buf: ::std::vec::Vec<u8> = ::std::vec::Vec::with_capacity(bytes.len() + 1);
for &b in bytes.iter() {
buf.push(if b == 0 { b' ' } else { b });
}
buf.push(0);
unsafe { ::std::ffi::CString::from_vec_unchecked(buf) }
}
#[inline]
pub unsafe fn write_slice_ptr_len(out_ptr: *mut *const u8, out_len: *mut usize, bytes: &[u8]) {
if out_ptr.is_null() || out_len.is_null() {
return;
}
*out_ptr = bytes.as_ptr();
*out_len = bytes.len();
}
#[inline]
pub fn build_runtime(thread_name: &'static str) -> Option<Runtime> {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.thread_name(thread_name)
.build()
.ok()
}