1#![allow(non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4
5use std::string::FromUtf8Error;
6
7include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
8
9pub fn char_arr_to_string(arr: &[u8]) -> Result<String, FromUtf8Error> {
10 String::from_utf8(arr.to_owned())
11}
12
13pub fn char_pointer_to_string(ptr: *mut i8) -> Result<String, FromUtf8Error> {
14 let mut len = 0;
15 while unsafe { *ptr.add(len) } != 0 {
16 len += 1;
17 }
18 let slice = unsafe { std::slice::from_raw_parts(ptr as *const u8, len) };
19 char_arr_to_string(slice)
20}