pub struct Config { /* private fields */ }Expand description
Runtime configuration for zwasm modules.
Allows fine-grained control over memory allocation, fuel, timeouts, and resource limits.
Used to customize the execution environment for a Module.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new() -> Result<Self, ZwasmError>
pub fn new() -> Result<Self, ZwasmError>
Creates a new runtime configuration for zwasm modules.
Use this to control memory allocation, fuel, timeouts, and other resource limits.
Sourcepub fn set_allocator<F, G>(&mut self, alloc_fn: F, free_fn: G)
pub fn set_allocator<F, G>(&mut self, alloc_fn: F, free_fn: G)
Sets custom memory allocation hooks for the zwasm runtime.
Allows you to override all memory allocation for Wasm execution. Useful for sandboxing or tracking allocations.
§Safety
The provided callbacks must obey allocator semantics for all (size, align) pairs
that the runtime may request. Returning invalid pointers or violating alignment/
deallocation contracts can cause undefined behavior in native code.
Sourcepub fn set_fuel(&mut self, fuel: u64)
pub fn set_fuel(&mut self, fuel: u64)
Sets the execution fuel limit for the module.
Fuel limits restrict the number of instructions a module can execute before trapping.
Sourcepub fn set_timeout(&mut self, timeout_ms: u64)
pub fn set_timeout(&mut self, timeout_ms: u64)
Sets the execution timeout (in milliseconds) for the module.
Execution will be interrupted if the timeout is exceeded.
Sourcepub fn set_max_memory(&mut self, max_memory: u64)
pub fn set_max_memory(&mut self, max_memory: u64)
Sets the maximum linear memory (in bytes) for the module.
Prevents Wasm modules from growing memory beyond this limit.
Sourcepub fn set_force_interpreter(&mut self, force: bool)
pub fn set_force_interpreter(&mut self, force: bool)
Forces interpreter mode (disables JIT) when true.
Useful for debugging or running on unsupported platforms.
Sourcepub fn set_cancelable(&mut self, cancelable: bool)
pub fn set_cancelable(&mut self, cancelable: bool)
Enables or disables cancellation support for the module.
When enabled, execution can be cancelled via Module::cancel.