Struct wasmedge_sdk::Caller
source · pub struct Caller { /* private fields */ }Expand description
Implementations§
source§impl Caller
impl Caller
sourcepub fn new(frame: CallingFrame) -> Self
pub fn new(frame: CallingFrame) -> Self
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.
sourcepub fn executor(&self) -> Option<&Executor>
pub fn executor(&self) -> Option<&Executor>
Returns the executor instance from this caller.
sourcepub fn executor_mut(&mut self) -> Option<&mut Executor>
pub fn executor_mut(&mut self) -> Option<&mut Executor>
Returns the mutable executor instance from this caller.
sourcepub fn instance(&self) -> Option<&Instance>
pub fn instance(&self) -> Option<&Instance>
Returns the module instance in this caller.
sourcepub fn instance_mut(&mut self) -> Option<&mut Instance>
pub fn instance_mut(&mut self) -> Option<&mut Instance>
Returns the mutable module instance in this caller.
sourcepub fn memory(&self, idx: u32) -> Option<Memory>
pub fn memory(&self, idx: u32) -> Option<Memory>
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 in0as 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.