pub unsafe trait StackCreator: Send + Sync {
// Required method
fn new_stack(&self, size: usize) -> Result<Box<dyn StackMemory>, Error>;
}
async
and runtime
only.Expand description
A stack creator. Can be used to provide a stack creator to wasmtime which supplies stacks for async support.
§Safety
This trait is unsafe, as memory safety depends on a proper implementation of memory management. Stacks created by the StackCreator should always be treated as owned by an wasmtime instance, and any modification of them outside of wasmtime invoked routines is unsafe and may lead to corruption.
Note that this is a relatively new and experimental feature and it is recommended to be familiar with wasmtime runtime code to use it.
Required Methods§
Sourcefn new_stack(&self, size: usize) -> Result<Box<dyn StackMemory>, Error>
fn new_stack(&self, size: usize) -> Result<Box<dyn StackMemory>, Error>
Create a new StackMemory
object with the specified size.
The size
parameter is the expected size of the stack without any guard pages.
Note there should be at least one guard page of protected memory at the bottom of the stack to catch potential stack overflow scenarios. Additionally, stacks should be page aligned and zero filled.