JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

insanity

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨6ea28ab

⁨giterated-abi/src/callback/mod.rs⁩ - ⁨489⁩ bytes
Raw
1 pub mod operation;
2 pub mod setting;
3 pub mod value;
4
5 use std::marker::PhantomData;
6
7 pub trait Callback {
8 type CallbackFunc;
9 }
10
11 #[derive(Copy, Clone)]
12 #[repr(C)]
13 pub struct CallbackPtr<T: Callback> {
14 callback_ptr: *const (),
15 func: T::CallbackFunc,
16 _marker: PhantomData<T>,
17 }
18
19 impl<T: Callback> CallbackPtr<T> {
20 pub unsafe fn from_raw(data: T, func: T::CallbackFunc) -> Self {
21 todo!()
22 }
23
24 pub fn func(&self) -> &T::CallbackFunc {
25 &self.func
26 }
27 }
28