use std::fmt;
use std::future::Future;
use std::pin::Pin;
pub struct WorkIo {
pub call_again: bool,
pub finished: bool,
#[cfg(not(target_arch = "wasm32"))]
pub block_on: Option<Pin<Box<dyn Future<Output = ()> + Send>>>,
#[cfg(target_arch = "wasm32")]
pub block_on: Option<Pin<Box<dyn Future<Output = ()>>>>,
}
impl WorkIo {
#[cfg(not(target_arch = "wasm32"))]
pub fn block_on<F: Future<Output = ()> + Send + 'static>(&mut self, f: F) {
self.block_on = Some(Box::pin(f));
}
#[cfg(target_arch = "wasm32")]
pub fn block_on<F: Future<Output = ()> + 'static>(&mut self, f: F) {
self.block_on = Some(Box::pin(f));
}
}
impl fmt::Debug for WorkIo {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("WorkIo")
.field("call_again", &self.call_again)
.field("finished", &self.finished)
.finish()
}
}