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
use crate::cql;
mod acts;
pub use self::acts::*;
pub struct ObjProxy {
h: cql::c_h,
}
impl Drop for ObjProxy {
fn drop(&mut self) {
self.free();
}
}
impl ObjProxy {
pub fn from_h(h: cql::c_h) -> Self {
Self { h }
}
pub fn ch(&self) -> cql::c_h {
self.h
}
pub fn take_ch(&mut self) -> cql::c_h {
let h_ = self.h;
self.h = std::ptr::null_mut();
h_
}
pub fn free(&self) {
if self.h != std::ptr::null_mut() {
unsafe {
cql::obj_free(&self.h as *const _);
}
}
}
}