1 /// @brief 由bindgen生成的结构体转换成rust原生定义的结构体的特性
2 pub trait FFIBind2Rust<T> {
3     /// 转换为不可变引用
convert_ref(src: *const T) -> Option<&'static Self>4     fn convert_ref(src: *const T) -> Option<&'static Self>;
5     /// 转换为可变引用
convert_mut(src: *mut T) -> Option<&'static mut Self>6     fn convert_mut(src: *mut T) -> Option<&'static mut Self>;
7 }
8 
9 
10 
__convert_mut<'a, S, D>(src:*mut S) ->Option<&'a mut D>11 pub fn __convert_mut<'a, S, D>(src:*mut S) ->Option<&'a mut D>{
12     return unsafe {
13         core::mem::transmute::<
14             *mut S,
15             *mut D,
16         >(src)
17         .as_mut()
18     };
19 }
20 
__convert_ref<'a, S, D>(src:*const S) ->Option<&'a D>21 pub fn __convert_ref<'a, S, D>(src:*const S) ->Option<&'a D>{
22     return unsafe {
23         core::mem::transmute::<
24             *const S,
25             *const D,
26         >(src)
27         .as_ref()
28     };
29 }
30