use std::ffi::{CStr, CString}; use std::os::raw::c_char; use crate::Result; pub unsafe fn string_from_c_char_star(ptr: *mut c_char) -> Result { let c_str = CStr::from_ptr(ptr); let s = c_str.to_str()?; Ok(s.to_owned()) } pub fn c_char_star_from_string(s: impl AsRef) -> Result<*mut c_char> { let c_str = CString::new(s.as_ref().as_bytes())?; Ok(c_str.into_raw()) }