Trait wasmtime::ResourceLimiter[][src]

pub trait ResourceLimiter {
    fn memory_growing(
        &self,
        current: u32,
        desired: u32,
        maximum: Option<u32>
    ) -> bool;
fn table_growing(
        &self,
        current: u32,
        desired: u32,
        maximum: Option<u32>
    ) -> bool; fn instances(&self) -> usize { ... }
fn tables(&self) -> usize { ... }
fn memories(&self) -> usize { ... } }
Expand description

Used by hosts to limit resource consumption of instances at runtime.

Store::new_with_limits can be used with a resource limiter to take into account non-WebAssembly resource usage to determine if a linear memory or table should be grown.

Required methods

fn memory_growing(
    &self,
    current: u32,
    desired: u32,
    maximum: Option<u32>
) -> bool
[src]

Notifies the resource limiter that an instance’s linear memory has been requested to grow.

  • current is the current size of the linear memory in WebAssembly page units.
  • desired is the desired size of the linear memory in WebAssembly page units.
  • maximum is either the linear memory’s maximum or a maximum from an instance allocator, also in WebAssembly page units. A value of None indicates that the linear memory is unbounded.

This function should return true to indicate that the growing operation is permitted or false if not permitted.

Note that this function will be called even when the desired count exceeds the given maximum.

Returning true when a maximum has been exceeded will have no effect as the linear memory will not be grown.

fn table_growing(
    &self,
    current: u32,
    desired: u32,
    maximum: Option<u32>
) -> bool
[src]

Notifies the resource limiter that an instance’s table has been requested to grow.

  • current is the current number of elements in the table.
  • desired is the desired number of elements in the table.
  • maximum is either the table’s maximum or a maximum from an instance allocator, A value of None indicates that the table is unbounded.

This function should return true to indicate that the growing operation is permitted or false if not permitted.

Note that this function will be called even when the desired count exceeds the given maximum.

Returning true when a maximum has been exceeded will have no effect as the table will not be grown.

Provided methods

fn instances(&self) -> usize[src]

The maximum number of instances that can be created for a Store.

Module instantiation will fail if this limit is exceeded.

This value defaults to 10,000.

fn tables(&self) -> usize[src]

The maximum number of tables that can be created for a Store.

Module instantiation will fail if this limit is exceeded.

This value defaults to 10,000.

fn memories(&self) -> usize[src]

The maximum number of linear memories that can be created for a Store.

Instantiation will fail with an error if this limit is exceeded.

This value defaults to 10,000.

Implementors

impl ResourceLimiter for StoreLimits[src]

fn memory_growing(
    &self,
    _current: u32,
    desired: u32,
    _maximum: Option<u32>
) -> bool
[src]

fn table_growing(
    &self,
    _current: u32,
    desired: u32,
    _maximum: Option<u32>
) -> bool
[src]

fn instances(&self) -> usize[src]

fn tables(&self) -> usize[src]

fn memories(&self) -> usize[src]