Enum lunatic::WasmModule
source · pub enum WasmModule {
Module(u64),
Inherit,
}
Expand description
A compiled instance of a WebAssembly module.
Creating a module will also JIT compile it, this can be a compute-intensive tasks.
Variants§
Implementations§
source§impl WasmModule
impl WasmModule
sourcepub fn new(data: &[u8]) -> Result<Self, LunaticError>
pub fn new(data: &[u8]) -> Result<Self, LunaticError>
Compiles a WebAssembly module.
Once a module is compiled, functions like spawn
can be
used to spawn new processes from it.
sourcepub fn id(&self) -> i64
pub fn id(&self) -> i64
Returns the id of the module resource or -1 in case it’s an inherited module.
sourcepub fn spawn<M, S>(
&self,
function: &str,
params: &[Param]
) -> Result<Process<M, S>, LunaticError>where
S: CanSerialize<M>,
pub fn spawn<M, S>( &self, function: &str, params: &[Param] ) -> Result<Process<M, S>, LunaticError>where S: CanSerialize<M>,
Spawn a new process and use function
as the entry point. If the
function takes arguments the passed in params
need to exactly
match their types.
sourcepub fn spawn_config<M, S>(
&self,
function: &str,
params: &[Param],
config: &ProcessConfig
) -> Result<Process<M, S>, LunaticError>where
S: CanSerialize<M>,
pub fn spawn_config<M, S>( &self, function: &str, params: &[Param], config: &ProcessConfig ) -> Result<Process<M, S>, LunaticError>where S: CanSerialize<M>,
Spawn a new process with a configuration, and use function
as the
entry point. If the function takes arguments the passed in params
need to exactly match their types.
sourcepub fn spawn_link<M, S>(
&self,
function: &str,
params: &[Param],
tag: Tag
) -> Result<Process<M, S>, LunaticError>where
S: CanSerialize<M>,
pub fn spawn_link<M, S>( &self, function: &str, params: &[Param], tag: Tag ) -> Result<Process<M, S>, LunaticError>where S: CanSerialize<M>,
Spawn a new process and link it to the current one with the tag
.
sourcepub fn spawn_link_config<M, S>(
&self,
function: &str,
params: &[Param],
config: &ProcessConfig,
tag: Tag
) -> Result<Process<M, S>, LunaticError>where
S: CanSerialize<M>,
pub fn spawn_link_config<M, S>( &self, function: &str, params: &[Param], config: &ProcessConfig, tag: Tag ) -> Result<Process<M, S>, LunaticError>where S: CanSerialize<M>,
Spawn a new process with a configuration, and link it to the current one
with the tag
.