1use std::{
2 borrow::Borrow,
3 future::Future,
4 marker::{PhantomData, PhantomPinned},
5 ops::Deref,
6 pin::Pin,
7 task::{Context, Poll},
8};
9
10use isoprenoid::runtime::SignalsRuntimeRef;
11
12use crate::traits::{Guard, UnmanagedSignal, UnmanagedSignalCell};
13
14pub enum Opaque {}
15
16impl<T: ?Sized + Send, SR: ?Sized + SignalsRuntimeRef> UnmanagedSignal<T, SR> for Opaque {
17 fn touch(self: Pin<&Self>) {
18 match *self {}
19 }
20
21 fn get_clone(self: Pin<&Self>) -> T
22 where
23 T: Sync + Clone,
24 {
25 match *self {}
26 }
27
28 fn get_clone_exclusive(self: Pin<&Self>) -> T
29 where
30 T: Clone,
31 {
32 match *self {}
33 }
34
35 fn read<'r>(self: Pin<&'r Self>) -> OpaqueGuard<T>
36 where
37 Self: Sized,
38 T: 'r + Sync,
39 {
40 match *self {}
41 }
42
43 type Read<'r>
44 = OpaqueGuard<T>
45 where
46 Self: 'r + Sized,
47 T: 'r + Sync;
48
49 fn read_exclusive<'r>(self: Pin<&'r Self>) -> OpaqueGuard<T>
50 where
51 Self: Sized,
52 T: 'r,
53 {
54 match *self {}
55 }
56
57 type ReadExclusive<'r>
58 = OpaqueGuard<T>
59 where
60 Self: 'r + Sized,
61 T: 'r;
62
63 fn read_dyn<'r>(self: Pin<&'r Self>) -> Box<dyn 'r + Guard<T>>
64 where
65 T: 'r + Sync,
66 {
67 match *self {}
68 }
69
70 fn read_exclusive_dyn<'r>(self: Pin<&'r Self>) -> Box<dyn 'r + Guard<T>>
71 where
72 T: 'r,
73 {
74 match *self {}
75 }
76
77 fn subscribe(self: Pin<&Self>) {
78 match *self {}
79 }
80
81 fn unsubscribe(self: Pin<&Self>) {
82 match *self {}
83 }
84
85 fn clone_runtime_ref(&self) -> SR
86 where
87 SR: Sized,
88 {
89 match *self {}
90 }
91}
92
93impl<T: ?Sized + Send, SR: ?Sized + SignalsRuntimeRef> UnmanagedSignalCell<T, SR> for Opaque {
94 fn change(self: Pin<&Self>, _: T)
95 where
96 T: 'static + Sized + PartialEq,
97 {
98 match *self {}
99 }
100
101 fn replace(self: Pin<&Self>, _: T)
102 where
103 T: 'static + Sized,
104 {
105 match *self {}
106 }
107
108 fn update(
109 self: Pin<&Self>,
110 _: impl 'static + Send + FnOnce(&mut T) -> isoprenoid::runtime::Propagation,
111 ) where
112 Self: Sized,
113 T: 'static,
114 {
115 match *self {}
116 }
117
118 fn update_dyn(
119 self: Pin<&Self>,
120 _: Box<dyn 'static + Send + FnOnce(&mut T) -> isoprenoid::runtime::Propagation>,
121 ) where
122 T: 'static,
123 {
124 match *self {}
125 }
126
127 fn change_eager<'f>(self: Pin<&Self>, _: T) -> OpaqueFuture<Result<Result<T, T>, T>>
128 where
129 Self: 'f + Sized,
130 T: 'f + Sized + PartialEq,
131 {
132 match *self {}
133 }
134
135 type ChangeEager<'f>
136 = OpaqueFuture<Result<Result<T, T>, T>>
137 where
138 Self: 'f + Sized,
139 T: 'f + Sized;
140
141 fn replace_eager<'f>(self: Pin<&Self>, _: T) -> OpaqueFuture<Result<T, T>>
142 where
143 Self: 'f + Sized,
144 T: 'f + Sized,
145 {
146 match *self {}
147 }
148
149 type ReplaceEager<'f>
150 = OpaqueFuture<Result<T, T>>
151 where
152 Self: 'f + Sized,
153 T: 'f + Sized;
154
155 fn update_eager<
156 'f,
157 U: 'f + Send,
158 F: 'f + Send + FnOnce(&mut T) -> (isoprenoid::runtime::Propagation, U),
159 >(
160 self: Pin<&Self>,
161 _: F,
162 ) -> OpaqueFuture<Result<U, F>>
163 where
164 Self: 'f + Sized,
165 {
166 match *self {}
167 }
168
169 type UpdateEager<'f, U: 'f, F: 'f>
170 = OpaqueFuture<Result<U, F>>
171 where
172 Self: 'f + Sized;
173
174 fn change_eager_dyn<'f>(
175 self: Pin<&Self>,
176 _: T,
177 ) -> Box<dyn 'f + Send + Future<Output = Result<Result<T, T>, T>>>
178 where
179 T: 'f + Sized + PartialEq,
180 {
181 match *self {}
182 }
183
184 fn replace_eager_dyn<'f>(
185 self: Pin<&Self>,
186 _: T,
187 ) -> Box<dyn 'f + Send + Future<Output = Result<T, T>>>
188 where
189 T: 'f + Sized,
190 {
191 match *self {}
192 }
193
194 fn update_eager_dyn<'f>(
195 self: Pin<&Self>,
196 _: Box<dyn 'f + Send + FnOnce(&mut T) -> isoprenoid::runtime::Propagation>,
197 ) -> Box<
198 dyn 'f
199 + Send
200 + Future<
201 Output = Result<
202 (),
203 Box<dyn 'f + Send + FnOnce(&mut T) -> isoprenoid::runtime::Propagation>,
204 >,
205 >,
206 >
207 where
208 T: 'f,
209 {
210 match *self {}
211 }
212
213 fn change_blocking(&self, _: T) -> Result<T, T>
214 where
215 T: Sized + PartialEq,
216 {
217 match *self {}
218 }
219
220 fn replace_blocking(&self, _: T) -> T
221 where
222 T: Sized,
223 {
224 match *self {}
225 }
226
227 fn update_blocking<U>(
228 &self,
229 _: impl FnOnce(&mut T) -> (isoprenoid::runtime::Propagation, U),
230 ) -> U
231 where
232 Self: Sized,
233 {
234 match *self {}
235 }
236
237 fn update_blocking_dyn(
238 &self,
239 _: Box<dyn '_ + FnOnce(&mut T) -> isoprenoid::runtime::Propagation>,
240 ) {
241 match *self {}
242 }
243}
244
245pub struct OpaqueFuture<T> {
246 _phantom: (PhantomData<T>, PhantomPinned),
247 _vacant: Opaque,
248}
249
250unsafe impl<T> Send for OpaqueFuture<T> {}
254
255impl<T> Future for OpaqueFuture<T> {
256 type Output = T;
257
258 fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
259 match self._vacant {}
260 }
261}
262
263pub struct OpaqueGuard<T: ?Sized> {
264 pub(crate) _phantom: PhantomData<T>,
265 pub(crate) _vacant: Opaque,
266}
267
268impl<T: ?Sized> Guard<T> for OpaqueGuard<T> {}
269
270impl<T: ?Sized> Deref for OpaqueGuard<T> {
271 type Target = T;
272
273 fn deref(&self) -> &Self::Target {
274 match self._vacant {}
275 }
276}
277
278impl<T: ?Sized> Borrow<T> for OpaqueGuard<T> {
279 fn borrow(&self) -> &T {
280 match self._vacant {}
281 }
282}