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
use vapoursynth_sys as ffi;
use api::API;
#[derive(Debug)]
pub struct Function {
handle: *mut ffi::VSFuncRef,
}
unsafe impl Send for Function {}
unsafe impl Sync for Function {}
impl Drop for Function {
#[inline]
fn drop(&mut self) {
unsafe {
API::get_cached().free_func(self.handle);
}
}
}
impl Clone for Function {
#[inline]
fn clone(&self) -> Self {
let handle = unsafe { API::get_cached().clone_func(self.handle) };
Self { handle }
}
}
impl Function {
#[inline]
pub(crate) unsafe fn from_ptr(handle: *mut ffi::VSFuncRef) -> Self {
Self { handle }
}
#[inline]
pub(crate) fn ptr(&self) -> *mut ffi::VSFuncRef {
self.handle
}
}