Struct wasmtime::Caller[][src]

pub struct Caller<'a> { /* fields omitted */ }
Expand description

A structure representing the caller’s context when creating a function via Func::wrap.

This structure can be taken as the first parameter of a closure passed to Func::wrap, and it can be used to learn information about the caller of the function, such as the calling module’s memory, exports, etc.

The primary purpose of this structure is to provide access to the caller’s information, namely it’s exported memory and exported functions. This allows functions which take pointers as arguments to easily read the memory the pointers point into, or if a function is expected to call malloc in the wasm module to reserve space for the output you can do that.

Note that this Caller type a pretty temporary mechanism for accessing the caller’s information until interface types has been fully standardized and implemented. The interface types proposal will obsolete this type and this will be removed in the future at some point after interface types is implemented. If you’re relying on this Caller type it’s recommended to become familiar with interface types to ensure that your use case is covered by the proposal.

Implementations

impl Caller<'_>[src]

pub fn get_export(&self, name: &str) -> Option<Extern>[src]

Looks up an export from the caller’s module by the name given.

Note that this function is only implemented for the Extern::Memory and the Extern::Func types currently. No other exported structures can be acquired through this just yet, but this may be implemented in the future!

Note that when accessing and calling exported functions, one should adhere to the guidelines of the interface types proposal.

Return

If a memory or function export with the name provided was found, then it is returned as a Memory. There are a number of situations, however, where the memory or function may not be available:

  • The caller instance may not have an export named name
  • The export named name may not be an exported memory
  • There may not be a caller available, for example if Func was called directly from host code.

It’s recommended to take care when calling this API and gracefully handling a None return value.

pub fn store(&self) -> &Store[src]

Get a reference to the caller’s store.

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Caller<'a>

impl<'a> !Send for Caller<'a>

impl<'a> !Sync for Caller<'a>

impl<'a> Unpin for Caller<'a>

impl<'a> !UnwindSafe for Caller<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Pointable for T

pub const ALIGN: usize

The alignment of pointer.

type Init = T

The type for initializers.

pub unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more

pub unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more

pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more

pub unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V