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-abi/src/future.rs⁩ - ⁨1337⁩ bytes
Raw
1 use std::marker::PhantomData;
2
3 use crate::{FfiValue, FfiValueMut};
4
5 #[repr(C)]
6 pub struct FfiFuture<Output> {
7 poll_fn: unsafe extern "C" fn(FfiValueMut<FfiFuture<()>>, FfiValueMut<()>) -> RuntimeFuturePoll,
8 wake_fn: unsafe extern "C" fn(FfiValueMut<FfiFuture<()>>, FfiValueMut<()>),
9
10 poll_state: FfiValue<()>,
11 pub waker_state: Option<FfiValue<()>>,
12
13 _output_marker: PhantomData<Output>,
14 }
15
16 unsafe impl<Output> Send for FfiFuture<Output> where Output: Send {}
17 unsafe impl<Output> Sync for FfiFuture<Output> where Output: Sync {}
18
19 impl<Output> FfiFuture<Output> {
20 /// Docs here!
21 /// # SAFETY
22 /// TODO :(
23 pub unsafe fn poll(&mut self) -> RuntimeFuturePoll {
24 todo!()
25 }
26
27 /// Docs here!
28 /// # SAFETY
29 /// TODO :(
30 pub unsafe fn from_raw<PS>(
31 _poll_fn: unsafe extern "C" fn(
32 FfiValueMut<FfiFuture<()>>,
33 FfiValueMut<()>,
34 ) -> RuntimeFuturePoll,
35 _poll_state: PS,
36 ) -> Self {
37 todo!()
38 }
39
40 /// Docs here!
41 /// # SAFETY
42 /// Very not in progress text :)
43 pub unsafe fn write_waker<WS>(
44 &mut self,
45 _wake_fn: unsafe extern "C" fn(FfiValueMut<FfiFuture<()>>),
46 _waker_state: WS,
47 ) {
48 todo!()
49 }
50 }
51
52 #[repr(C)]
53 pub enum RuntimeFuturePoll {
54 Ready(FfiValue<()>),
55 Pending,
56 }
57