How to transform vector to ffi

pub struct Test{
    pub a: Vec<u8>,
    pub b: Vec<u8>,
    pub c: Vec<u8>,
    pub d: usize,
}

i want to parse that struct to C code
such like

typedef struct{
uint8_t* a,
uint8_t* b,
uint8_t* c,
size_t d
}

but it seem like i need to call

ts:Test;
ts.a.as_ptr()

to convert a vec to raw point

could any body know how to parse this struct to c

do we need to wrap it in c

pub struct WrapC{
    pub a: const* u8,
    pub b: const* u8,
    pub c: const* u8,
    pub d: usize,
}

You already found the solution:

#[repr(C)]
pub struct WrapC{
    pub a: const* u8,
    pub b: const* u8,
    pub c: const* u8,
    pub d: usize,
}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.