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

ambee/giterated

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

Spinning

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨1788060

⁨giterated-core/src/lib.rs⁩ - ⁨2945⁩ bytes
Raw
1 use giterated_abi::vtable::{runtime::RuntimeHandle, VTable};
2 use giterated_models::{
3 error::OperationError,
4 object::{GiteratedObject, Object, ObjectRequestError},
5 object_backend::ObjectBackend,
6 operation::{GiteratedOperation, OperationState},
7 };
8 use std::fmt::Debug;
9
10 pub mod types;
11
12 #[derive(Clone)]
13 #[repr(C)]
14 pub struct RuntimeState {
15 pub vtable: &'static VTable<RuntimeHandle>,
16 }
17
18 #[async_trait::async_trait(?Send)]
19 impl ObjectBackend for RuntimeState {
20 async fn object_operation<O, D>(
21 &self,
22 object: O,
23 operation: &str,
24 payload: D,
25 operation_state: &OperationState,
26 ) -> Result<D::Success, OperationError<D::Failure>>
27 where
28 O: GiteratedObject + Debug + 'static,
29 D: GiteratedOperation<O> + Debug + 'static,
30 D::Success: Clone,
31 D::Failure: Clone,
32 {
33 todo!()
34 }
35
36 async fn get_object<O: GiteratedObject + Debug + 'static>(
37 &self,
38 object_str: &str,
39 operation_state: &OperationState,
40 ) -> Result<Object<O, Self>, OperationError<ObjectRequestError>> {
41 todo!()
42 }
43 }
44
45 // impl RuntimeState {
46 // pub unsafe fn from_static() -> Self {
47 // let runtime = giterated_static_runtime::get_runtime_reference();
48
49 // let runtime = runtime.cast::<Box<Runtime>>().as_ref();
50
51 // runtime.state()
52 // }
53
54 // pub unsafe fn runtime_state() -> PluginState {
55 // let runtime = giterated_static_runtime::get_runtime_reference();
56
57 // PluginState::from_raw_ptr(giterated_static_runtime::get_runtime_reference().as_ptr())
58 // }
59 // }
60
61 // #[async_trait::async_trait(?Send)]
62 // impl ObjectBackend for RuntimeState {
63 // async fn object_operation<O, D>(
64 // &self,
65 // object: O,
66 // _operation: &str,
67 // payload: D,
68 // _operation_state: &OperationState,
69 // ) -> Result<D::Success, OperationError<D::Failure>>
70 // where
71 // O: GiteratedObject + Debug + 'static,
72 // D: GiteratedOperation<O> + Debug + 'static,
73 // D::Success: Clone,
74 // D::Failure: Clone,
75 // {
76 // // let _object = AnyObject::new(object);
77 // // let _operation = AnyOperation::new(payload);
78
79 // todo!()
80 // }
81
82 // async fn get_object<O: GiteratedObject + Debug + 'static>(
83 // &self,
84 // object_str: &str,
85 // operation_state: &OperationState,
86 // ) -> Result<Object<O, Self>, OperationError<ObjectRequestError>> {
87 // // let object = unsafe {
88 // // (self.vtable.get_object)(
89 // // Self::runtime_state(),
90 // // object_str,
91 // // &mut operation_state.clone(),
92 // // )
93 // // }?;
94
95 // // let object = unsafe { object.cast::<O>() };
96
97 // panic!("object casted");
98
99 // // Ok(unsafe { Object::new_unchecked(object, self.clone()) })
100
101 // todo!()
102 // }
103 // }
104