cxx icon indicating copy to clipboard operation
cxx copied to clipboard

How to add can_frame to the bindings?

Open hanusek opened this issue 3 years ago • 0 comments

Hello! I would like to use can_frame in my bindings. I need to use my rust's library in C++. I need to create can_frame in rust and pass it to C++. How to do it? Can you help me?

use cxx::{CxxString, CxxVector,};

#[cxx::bridge]
mod ffi {
    unsafe extern "C++" {
        include!("<can.h>");
        type can_frame;
    }
    
    #[namespace = "rust_part"]
    extern "Rust" 
    {
            unsafe fn encode_frame(frame_id: &CxxString) -> can_frame;
    }
}

hanusek avatar Jun 14 '22 14:06 hanusek