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

ambee/giterated

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

Wow!

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨6530104

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