Struct tp_sandbox::Instance[][src]

pub struct Instance<T> { /* fields omitted */ }

Sandboxed instance of a wasm module.

This instance can be used for invoking exported functions.

Implementations

impl<T> Instance<T>[src]

pub fn new(
    code: &[u8],
    env_def_builder: &EnvironmentDefinitionBuilder<T>,
    state: &mut T
) -> Result<Instance<T>, Error>
[src]

Instantiate a module with the given EnvironmentDefinitionBuilder. It will run the start function (if it is present in the module) with the given state.

Returns Err(Error::Module) if this module can’t be instantiated with the given environment. If execution of start function generated a trap, then Err(Error::Execution) will be returned.

pub fn invoke(
    &mut self,
    name: &str,
    args: &[Value],
    state: &mut T
) -> Result<ReturnValue, Error>
[src]

Invoke an exported function with the given name.

Errors

Returns Err(Error::Execution) if:

  • An export function name isn’t a proper utf8 byte sequence,
  • This module doesn’t have an exported function with the given name,
  • If types of the arguments passed to the function doesn’t match function signature then trap occurs (as if the exported function was called via call_indirect),
  • Trap occurred at the execution time.

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

Get the value from a global with the given name.

Returns Some(_) if the global could be found.

Auto Trait Implementations

impl<T> !RefUnwindSafe for Instance<T>

impl<T> !Send for Instance<T>

impl<T> !Sync for Instance<T>

impl<T> Unpin for Instance<T> where
    T: Unpin

impl<T> !UnwindSafe for Instance<T>

Blanket Implementations

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

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

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

impl<T> Downcast for T where
    T: Any

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

impl<T> Instrument for T[src]

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

impl<T, Outer> IsWrappedBy<Outer> for T where
    T: From<Outer>,
    Outer: AsRef<T> + AsMut<T> + From<T>, 
[src]

pub fn from_ref(outer: &Outer) -> &T[src]

Get a reference to the inner from the outer.

pub fn from_mut(outer: &mut Outer) -> &mut T[src]

Get a mutable reference to the inner from the outer.

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.

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.

impl<S, T> UncheckedInto<T> for S where
    T: UncheckedFrom<S>, 
[src]

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