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-core/src/lib.rs⁩ - ⁨1794⁩ bytes
Raw
1 mod state;
2 mod types;
3
4 #[derive(Clone)]
5 #[repr(C)]
6 pub struct RuntimeState {
7 pub vtable: VTable<RuntimeState>,
8 }
9
10 impl RuntimeState {
11 pub unsafe fn from_static() -> Self {
12 let runtime = giterated_static_runtime::get_runtime_reference();
13
14 let runtime = runtime.cast::<Box<Runtime>>().as_ref();
15
16 runtime.state()
17 }
18
19 pub unsafe fn runtime_state() -> PluginState {
20 let runtime = giterated_static_runtime::get_runtime_reference();
21
22 PluginState::from_raw_ptr(giterated_static_runtime::get_runtime_reference().as_ptr())
23 }
24 }
25
26 #[async_trait::async_trait(?Send)]
27 impl ObjectBackend for RuntimeState {
28 async fn object_operation<O, D>(
29 &self,
30 object: O,
31 _operation: &str,
32 payload: D,
33 _operation_state: &OperationState,
34 ) -> Result<D::Success, OperationError<D::Failure>>
35 where
36 O: GiteratedObject + Debug + 'static,
37 D: GiteratedOperation<O> + Debug + 'static,
38 D::Success: Clone,
39 D::Failure: Clone,
40 {
41 // let _object = AnyObject::new(object);
42 // let _operation = AnyOperation::new(payload);
43
44 todo!()
45 }
46
47 async fn get_object<O: GiteratedObject + Debug + 'static>(
48 &self,
49 object_str: &str,
50 operation_state: &OperationState,
51 ) -> Result<Object<O, Self>, OperationError<ObjectRequestError>> {
52 // let object = unsafe {
53 // (self.vtable.get_object)(
54 // Self::runtime_state(),
55 // object_str,
56 // &mut operation_state.clone(),
57 // )
58 // }?;
59
60 // let object = unsafe { object.cast::<O>() };
61
62 panic!("object casted");
63
64 // Ok(unsafe { Object::new_unchecked(object, self.clone()) })
65
66 todo!()
67 }
68 }
69