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

ambee/giterated

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

MOre pre vtable changes

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨9cfa135

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