Struct wasmtime::Caller

source ·
pub struct Caller<'a, T> { /* private fields */ }
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 or other constructors, and serves two purposes:

  • First consumers can use Caller<'_, T> to get access to StoreContextMut<'_, T> and/or get access to T itself. This means that the Caller type can serve as a proxy to the original Store itself and is used to satisfy AsContext and AsContextMut bounds.

  • Second a Caller can be used as the name implies, learning about the caller’s context, 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.

Host functions which want access to Store-level state are recommended to use this type.

Implementations§

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

This is a low-level function that’s typically used to implement passing of pointers or indices between core Wasm instances, where the callee needs to consult the caller’s exports to perform memory management and resolve the references.

For comparison, in components, the component model handles translating arguments from one component instance to another and managing memory, so that callees don’t need to be aware of their callers, which promotes virtualizability of APIs.

Return

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

  • The caller instance may not have an export named name
  • 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.

Access the underlying data owned by this Store.

Same as Store::data

Access the underlying data owned by this Store.

Same as Store::data_mut

Returns the underlying Engine this store is connected to.

Perform garbage collection of ExternRefs.

Same as Store::gc.

Returns the fuel consumed by this store.

For more information see Store::fuel_consumed

Inject more fuel into this store to be consumed when executing wasm code.

For more information see Store::add_fuel

Synthetically consumes fuel from the store.

For more information see Store::consume_fuel

Configures this Store to trap whenever fuel runs out.

For more information see Store::out_of_fuel_trap

Configures this Store to yield while executing futures whenever fuel runs out.

For more information see Store::out_of_fuel_async_yield

Trait Implementations§

The host information associated with the Store, aka the T in Store<T>. Read more
Returns the store context that this type provides access to.
Returns the store context that this type provides access to.

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 alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
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.