use giterated_abi::{ result::{FfiError, FfiResult}, value_ex::FfiValueUntyped, vtable::Object, FfiSliceRef, }; use giterated_models::{ error::OperationError, object::ObjectRequestError, operation::OperationState, }; use crate::{ future::RuntimeFuture, new_stack::{PluginState, TypeMetadata}, }; #[derive(Clone, Copy)] pub struct RuntimeVTable { pub(crate) runtime: PluginState, pub(crate) type_metadata: *const TypeMetadata, pub(crate) handle_fn: unsafe extern "C" fn( PluginState, FfiSliceRef, FfiSliceRef, FfiSliceRef, FfiSliceRef<[u8]>, FfiSliceRef<[u8]>, ) -> RuntimeFuture< FfiResult>, >, pub(crate) get_object: unsafe extern "C" fn( PluginState, &str, *mut OperationState, ) -> FfiResult>, } unsafe impl Send for RuntimeVTable {} unsafe impl Sync for RuntimeVTable {} pub trait IntoRuntimeVtable { unsafe extern "C" fn handle( this: PluginState, object_kind: FfiSliceRef, operation_name: FfiSliceRef, object: FfiSliceRef, operation_payload: FfiSliceRef<[u8]>, operation_state: FfiSliceRef<[u8]>, ) -> RuntimeFuture>>; unsafe extern "C" fn get_object( this: PluginState, object_str: &str, operation_state: *mut OperationState, ) -> FfiResult>; }