bindgen

How do I convert a static global variable generated by Bindgen into a global const?

☆樱花仙子☆ 提交于 2021-01-29 11:54:40
问题 Bindgen generates this from a static const C-style global structure: pub struct rmw_qos_profile_t { pub depth: usize, pub deadline: rmw_time_t, // ... } extern "C" { #[link_name = "\u{1}rmw_qos_profile_sensor_data"] pub static rmw_qos_profile_sensor_data: rmw_qos_profile_t; } I would like to safely bind it to a global const in Rust. My best attempt so far is impl From<rmw_qos_profile_t> for QoSProfile { fn from(qos_profile: rmw_qos_profile_t) -> Self { QoSProfile { depth: qos_profile.depth,