Struct Caller

Source
pub struct Caller<'a> { /* 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, 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, such as it’s exported memory. This allows functions which take pointers as arguments to easily read the memory the pointers point into.

Note that this is intended to be a pretty temporary mechanism for accessing the caller’s memory until interface types has been fully standardized and implemented.

Implementations§

Source§

impl Caller<'_>

Source

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

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

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

§Return

If a memory export with the name provided was found, then it is returned as a Memory. There are a number of situations, however, where the memory 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.

Source

pub fn store(&self) -> Store

Get a handle to this caller’s store.

Auto Trait Implementations§

§

impl<'a> Freeze for Caller<'a>

§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.