I use python cffi to call rust code.
rust code
#[no_mangle]
pub extern "C" fn fixU32_decode(raw: *const libc::c_char) -> *mut u32 {
let str_raw = unsafe { CStr::from_ptr(raw) }.to_str().unwrap().to_string();
let bytes_raw = hex::decode(str_raw).unwrap();
let mut u8_fixed: [u32; 6] = Decode::decode(&mut &bytes_raw[..]).unwrap();
println!("fixU32_decode input {:?}",u8_fixed);
let ptr = u8_fixed.as_mut_ptr();
std::mem::forget(u8_fixed);
ptr
}
Python
ffi = FFI()
ffi.cdef("""
unsigned int* fixU32_decode(char* raw);
""")
s1 = ffi.fixU32_decode("010000000200000003000000040000000500000006000000")
print(s1) # <cdata 'unsigned int *' 0x16b36629c>?
Add how to get return array from python use cffi