wasmer_wasix/utils/dummy_waker.rs
1/// A "mock" no-op [`std::task::Waker`] implementation.
2///
3/// Needed for polling futures outside of an async runtime, since the `poll()`
4/// functions requires a `[std::task::Context]` with a supplied waker.
5#[derive(Debug, Clone)]
6pub struct WasiDummyWaker;
7
8impl cooked_waker::Wake for WasiDummyWaker {
9 fn wake(self) {}
10}
11
12impl cooked_waker::WakeRef for WasiDummyWaker {
13 fn wake_by_ref(&self) {}
14}
15
16unsafe impl cooked_waker::ViaRawPointer for WasiDummyWaker {
17 type Target = ();
18 fn into_raw(self) -> *mut () {
19 std::ptr::null_mut()
20 }
21 unsafe fn from_raw(_ptr: *mut ()) -> Self {
22 WasiDummyWaker
23 }
24}