1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use crate::{c_api, NcIntResult, NcPlane};
pub type NcResizeCb = fn(&mut NcPlane) -> NcIntResult;
pub type NcResizeCbUnsafe = unsafe extern "C" fn(*mut NcPlane) -> NcIntResult;
pub(crate) mod reimplemented {
use super::*;
pub fn ncresizecb_to_rust(resizecb: Option<NcResizeCbUnsafe>) -> Option<NcResizeCb> {
resizecb.map(|cb| unsafe { core::mem::transmute(cb) })
}
pub fn ncresizecb_to_c(resizecb: Option<NcResizeCb>) -> Option<NcResizeCbUnsafe> {
resizecb.map(|cb| unsafe { core::mem::transmute(cb) })
}
}
pub trait NcResizeCbApi {
fn to_rust(&self) -> Option<NcResizeCb>;
fn to_c(&self) -> Option<NcResizeCbUnsafe>;
}
impl NcResizeCbApi for NcResizeCb {
fn to_c(&self) -> Option<NcResizeCbUnsafe> {
c_api::ncresizecb_to_c(Some(*self))
}
fn to_rust(&self) -> Option<NcResizeCb> {
Some(*self)
}
}
impl NcResizeCbApi for NcResizeCbUnsafe {
fn to_c(&self) -> Option<NcResizeCbUnsafe> {
Some(*self)
}
fn to_rust(&self) -> Option<NcResizeCb> {
c_api::ncresizecb_to_rust(Some(*self))
}
}