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

ambee/giterated

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

Structure refactoring

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨a8f41ac

⁨giterated-abi/src/vtable/runtime.rs⁩ - ⁨1614⁩ bytes
Raw
1 use giterated_abi::{
2 result::{FfiError, FfiResult},
3 value_ex::FfiValueUntyped,
4 vtable::Object,
5 FfiSliceRef,
6 };
7 use giterated_models::{
8 error::OperationError, object::ObjectRequestError, operation::OperationState,
9 };
10
11 use crate::{
12 future::RuntimeFuture,
13 new_stack::{PluginState, TypeMetadata},
14 };
15
16 #[derive(Clone, Copy)]
17 pub struct RuntimeVTable {
18 pub(crate) runtime: PluginState,
19 pub(crate) type_metadata: *const TypeMetadata,
20 pub(crate) handle_fn: unsafe extern "C" fn(
21 PluginState,
22 FfiSliceRef<str>,
23 FfiSliceRef<str>,
24 FfiSliceRef<str>,
25 FfiSliceRef<[u8]>,
26 FfiSliceRef<[u8]>,
27 ) -> RuntimeFuture<
28 FfiResult<FfiValueUntyped, OperationError<FfiError>>,
29 >,
30 pub(crate) get_object:
31 unsafe extern "C" fn(
32 PluginState,
33 &str,
34 *mut OperationState,
35 ) -> FfiResult<Object, OperationError<ObjectRequestError>>,
36 }
37
38 unsafe impl Send for RuntimeVTable {}
39 unsafe impl Sync for RuntimeVTable {}
40
41 pub trait IntoRuntimeVtable {
42 unsafe extern "C" fn handle(
43 this: PluginState,
44 object_kind: FfiSliceRef<str>,
45 operation_name: FfiSliceRef<str>,
46 object: FfiSliceRef<str>,
47 operation_payload: FfiSliceRef<[u8]>,
48 operation_state: FfiSliceRef<[u8]>,
49 ) -> RuntimeFuture<FfiResult<FfiValueUntyped, OperationError<FfiError>>>;
50
51 unsafe extern "C" fn get_object(
52 this: PluginState,
53 object_str: &str,
54 operation_state: *mut OperationState,
55 ) -> FfiResult<Object, OperationError<ObjectRequestError>>;
56 }
57