Skip to main content

WasmImports

Struct WasmImports 

Source
pub struct WasmImports {
    pub pd_send: Box<dyn Fn(*const u8, u32, *const u8, u32) -> i32 + Send + Sync + 'static>,
    pub pd_now_micros: Box<dyn Fn() -> u64 + Send + Sync + 'static>,
    pub pd_log: Box<dyn Fn(i32, *const u8, u32) + Send + Sync + 'static>,
}
Expand description

Host function callbacks injected into a WASM module at instantiation.

These correspond to the pd_* imports that a plugin WASM module may call. The closures receive raw pointers into a buffer that was read from WASM linear memory immediately before the call; the pointers are valid for the duration of the call only.

The + Send + Sync + 'static bounds are required because wasmtime host functions must be thread-safe. Use Default to obtain no-op stubs.

Fields§

§pd_send: Box<dyn Fn(*const u8, u32, *const u8, u32) -> i32 + Send + Sync + 'static>

Send a message to another actor.

Arguments: (envelope_ptr, envelope_len, payload_ptr, payload_len). Returns 0 on success, negative on error.

§pd_now_micros: Box<dyn Fn() -> u64 + Send + Sync + 'static>

Return the current engine time in microseconds.

§pd_log: Box<dyn Fn(i32, *const u8, u32) + Send + Sync + 'static>

Emit a log message.

Arguments: (level, msg_ptr, msg_len).

Trait Implementations§

Source§

impl Default for WasmImports

Source§

fn default() -> Self

No-op stubs — suitable for tests that don’t exercise host imports.

Auto Trait Implementations§

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, 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.
Source§

impl<T, U> Upcast<T> for U
where T: UpcastFrom<U>,

Source§

fn upcast(self) -> T

Source§

impl<T, B> UpcastFrom<Counter<T, B>> for T

Source§

fn upcast_from(value: Counter<T, B>) -> T

Source§

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

Source§

fn vzip(self) -> V