wiggle::wasmtime_crate

Trait ResourceLimiterAsync

pub trait ResourceLimiterAsync {
    // Required methods
    fn memory_growing<'life0, 'async_trait>(
        &'life0 mut self,
        current: usize,
        desired: usize,
        maximum: Option<usize>,
    ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn table_growing<'life0, 'async_trait>(
        &'life0 mut self,
        current: usize,
        desired: usize,
        maximum: Option<usize>,
    ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn memory_grow_failed(&mut self, error: Error) -> Result<(), Error> { ... }
    fn table_grow_failed(&mut self, error: Error) -> Result<(), Error> { ... }
    fn instances(&self) -> usize { ... }
    fn tables(&self) -> usize { ... }
    fn memories(&self) -> usize { ... }
}
Expand description

Used by hosts to limit resource consumption of instances, blocking asynchronously if necessary.

This trait is identical to ResourceLimiter, except that the memory_growing and table_growing functions are async. Must be used with an async Store configured via Config::async_support.

This trait is used with Store::limiter_async: see those docs for restrictions on using other Wasmtime interfaces with an async resource limiter. Additionally see [ResourceLimiter`] for more information about limiting resources from WebAssembly.

The async here enables embedders that are already using asynchronous execution of WebAssembly to block the WebAssembly, but no the OS thread, to answer the question whether growing a memory or table is allowed.

Required Methods§

fn memory_growing<'life0, 'async_trait>( &'life0 mut self, current: usize, desired: usize, maximum: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

fn table_growing<'life0, 'async_trait>( &'life0 mut self, current: usize, desired: usize, maximum: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Asynchronous version of ResourceLimiter::table_growing

Provided Methods§

fn memory_grow_failed(&mut self, error: Error) -> Result<(), Error>

fn table_grow_failed(&mut self, error: Error) -> Result<(), Error>

fn instances(&self) -> usize

fn tables(&self) -> usize

fn memories(&self) -> usize

Implementors§