Struct wasmedge_sdk::Caller

source ·
pub struct Caller { /* private fields */ }
Expand description

Represents the calling frame on top of stack.

The Caller object is only used as the first argument when defining a host function. With this argument, developers can have access to the Executor instance, the Instance instance, and the Memory instance inside the host functions they defined.

Implementations§

Creates a Caller instance with the given CallingFrame instance.

Caller vs. CallingFrame

CallingFrame is a low-level type defined in wasmedge-sys crate, while Caller is a high-level type. For developers using the APIs in wasmedge-sdk, they should create a Caller instance with the given CallingFrame instance, as Caller provides APIs to access high-level instances, such as executor and memory, related to the current calling frame.

Returns the executor instance from this caller.

Returns the mutable executor instance from this caller.

Returns the module instance in this caller.

Returns the mutable module instance in this caller.

Returns the memory instance by the given index from the module instance of this caller. If the memory instance is not found, then return None.

Arguments
  • idx - The index of the memory instance. By default, a WASM module has only one memory instance after instantiation. Therefore, users can pass in 0 as the index to get the memory instance in host function body. When the MultiMemories config option is enabled, there would be more than one memory instances in the wasm module. Users can retrieve the target memory instance by specifying the index of the memory instance in the wasm module instance.

Trait Implementations§

Formats the value using the given formatter. Read more
Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.