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§

§

Module(u64)

§

Inherit

Implementations§

source§

impl WasmModule

source

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.

source

pub fn id(&self) -> i64

Returns the id of the module resource or -1 in case it’s an inherited module.

source

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.

source

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.

Spawn a new process and link it to the current one with the tag.

Spawn a new process with a configuration, and link it to the current one with the tag.

Trait Implementations§

source§

impl<'de> Deserialize<'de> for WasmModule

source§

fn deserialize<D>(deserializer: D) -> Result<WasmModule, D::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Drop for WasmModule

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Serialize for WasmModule

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,