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 in0
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§
source§impl From<CallingFrame> for Caller
impl From<CallingFrame> for Caller
source§fn from(frame: CallingFrame) -> Self
fn from(frame: CallingFrame) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for Caller
impl Send for Caller
impl Sync for Caller
impl Unpin for Caller
impl !UnwindSafe for Caller
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more