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/vtable/runtime.rs⁩ - ⁨1437⁩ bytes
Raw
1 use giterated_models::{error::OperationError, object::ObjectRequestError};
2
3 use crate::{
4 result::{FfiError, FfiResult},
5 state::State,
6 value_ex::FfiValueUntyped,
7 FfiFuture, FfiSliceRef, FfiValueMut,
8 };
9
10 use super::{Object, ObjectABI};
11
12 pub struct Runtime {}
13
14 impl ObjectABI for Runtime {
15 type VTable = RuntimeVTable;
16 }
17
18 #[derive(Clone, Copy)]
19 pub struct RuntimeVTable {
20 pub(crate) handle_fn: unsafe extern "C" fn(
21 FfiSliceRef<str>,
22 FfiSliceRef<str>,
23 FfiSliceRef<str>,
24 FfiSliceRef<[u8]>,
25 FfiSliceRef<[u8]>,
26 ) -> FfiFuture<
27 FfiResult<FfiValueUntyped, OperationError<FfiError>>,
28 >,
29 pub(crate) get_object:
30 unsafe extern "C" fn(
31 &str,
32 state: FfiValueMut<State>,
33 ) -> FfiResult<Object, OperationError<ObjectRequestError>>,
34 }
35
36 unsafe impl Send for RuntimeVTable {}
37 unsafe impl Sync for RuntimeVTable {}
38
39 pub trait IntoRuntimeVtable {
40 unsafe extern "C" fn handle(
41 object_kind: FfiSliceRef<str>,
42 operation_name: FfiSliceRef<str>,
43 object: FfiSliceRef<str>,
44 operation_payload: FfiSliceRef<[u8]>,
45 operation_state: FfiSliceRef<[u8]>,
46 ) -> FfiFuture<FfiResult<FfiValueUntyped, OperationError<FfiError>>>;
47
48 unsafe extern "C" fn get_object(
49 object_str: &str,
50 operation_state: FfiValueMut<State>,
51 ) -> FfiResult<Object, OperationError<ObjectRequestError>>;
52 }
53