1 |
use std::marker::PhantomData;
|
2 |
|
3 |
pub trait Callback {
|
4 |
type CallbackFunc;
|
5 |
}
|
6 |
|
7 |
#[derive(Copy, Clone)]
|
8 |
#[repr(C)]
|
9 |
pub struct CallbackPtr<T: Callback> {
|
10 |
callback_ptr: *const (),
|
11 |
func: T::CallbackFunc,
|
12 |
_marker: PhantomData<T>,
|
13 |
}
|
14 |
|
15 |
impl<T: Callback> CallbackPtr<T> {
|
16 |
pub unsafe fn from_raw(data: T, func: T::CallbackFunc) -> Self {
|
17 |
todo!()
|
18 |
}
|
19 |
|
20 |
pub fn func(&self) -> &T::CallbackFunc {
|
21 |
&self.func
|
22 |
}
|
23 |
}
|
24 |
|