use
{
crate :: { import::*, RtErr, RtConfig } ,
wasm_bindgen_futures :: { spawn_local } ,
};
#[ derive( Debug ) ]
pub struct WasmExec
{
_config: RtConfig
}
impl Default for WasmExec
{
fn default() -> Self
{
WasmExec::new( RtConfig::default() )
}
}
impl WasmExec
{
pub fn new( config: RtConfig ) -> Self
{
match config
{
RtConfig::Local => WasmExec{ _config: config },
RtConfig::Pool => panic!( "Wasm does not have threads atm. Please initiate with a localpool executor" ),
}
}
pub fn config( &self ) -> &RtConfig
{
&self._config
}
pub fn spawn( &self, fut: impl Future< Output = () > + 'static + Send ) -> Result< (), RtErr >
{
spawn_local( fut );
Ok(())
}
pub fn spawn_local( &self, fut: impl Future< Output = () > + 'static ) -> Result< (), RtErr >
{
spawn_local( fut );
Ok(())
}
}