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

ambee/giterated

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

Before

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨e432306

⁨giterated-plugin/src/vtable/host.rs⁩ - ⁨1910⁩ bytes
Raw
1 use giterated_abi::{
2 callback::CallbackPtr,
3 vtable::{operation::Operation, Object, ObjectABI, Setting, VTable, Value},
4 };
5
6 use crate::{
7 callback::{OperationHandlerCallback, SettingGetterCallback, ValueGetterCallback},
8 handle::PluginInitializationState,
9 };
10 use std::fmt::Debug;
11
12 #[repr(C)]
13 pub struct HostVTable {}
14
15 #[repr(C)]
16 #[derive(Clone, Copy)]
17 pub struct Initialization {
18 pub register_object:
19 unsafe extern "C" fn(*mut PluginInitializationState, &'static str, &'static VTable<Object>),
20 pub register_operation: unsafe extern "C" fn(
21 *mut PluginInitializationState,
22 &'static str,
23 &'static str,
24 &'static VTable<Operation>,
25 ),
26 pub register_setting: unsafe extern "C" fn(
27 *mut PluginInitializationState,
28 &'static str,
29 &'static str,
30 &'static VTable<Setting>,
31 ),
32 pub register_value: unsafe extern "C" fn(
33 *mut PluginInitializationState,
34 &'static str,
35 &'static str,
36 &'static VTable<Value>,
37 ),
38
39 pub operation_handler: unsafe extern "C" fn(
40 *mut PluginInitializationState,
41 &'static str,
42 &'static str,
43 CallbackPtr<OperationHandlerCallback>,
44 ),
45
46 pub value_getter: unsafe extern "C" fn(
47 *mut PluginInitializationState,
48 &'static str,
49 &'static str,
50 CallbackPtr<ValueGetterCallback>,
51 ),
52
53 pub setting_getter: unsafe extern "C" fn(
54 *mut PluginInitializationState,
55 &'static str,
56 &'static str,
57 CallbackPtr<SettingGetterCallback>,
58 ),
59 }
60
61 impl ObjectABI for Initialization {
62 type VTable = Initialization;
63 }
64
65 impl Debug for Initialization {
66 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
67 f.debug_struct("InitializationVTable").finish()
68 }
69 }
70
71 unsafe impl Sync for Initialization {}
72 unsafe impl Send for Initialization {}
73