pub struct AsyncRuntime { /* private fields */ }Expand description
An async-enabled package runtime.
Use this when you need to register async host functions or call WASM functions asynchronously.
§Example
ⓘ
let runtime = AsyncRuntime::new();
let module = runtime.load_module(&wasm_bytes)?;
let instance = module.instantiate_with_host_async(MyState::new(), |builder| {
builder.interface("theater:runtime")?
.func_async("fetch", |ctx, url: String| {
Box::pin(async move {
// async operation here
fetch_url(&url).await
})
})?;
Ok(())
}).await?;
let result = instance.call_with_value_async("process", &input, 0).await?;Implementations§
Source§impl AsyncRuntime
impl AsyncRuntime
Sourcepub fn load_module(
&self,
wasm_bytes: &[u8],
) -> Result<AsyncCompiledModule<'_>, RuntimeError>
pub fn load_module( &self, wasm_bytes: &[u8], ) -> Result<AsyncCompiledModule<'_>, RuntimeError>
Load a WASM module from bytes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AsyncRuntime
impl !RefUnwindSafe for AsyncRuntime
impl Send for AsyncRuntime
impl Sync for AsyncRuntime
impl Unpin for AsyncRuntime
impl UnsafeUnpin for AsyncRuntime
impl !UnwindSafe for AsyncRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more