Struct tp_sandbox::Instance [−][src]
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]
code: &[u8],
env_def_builder: &EnvironmentDefinitionBuilder<T>,
state: &mut T
) -> Result<Instance<T>, Error>
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]
&mut self,
name: &str,
args: &[Value],
state: &mut T
) -> Result<ReturnValue, Error>
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,
T: Unpin,
impl<T> !UnwindSafe for Instance<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, Outer> IsWrappedBy<Outer> for T where
T: From<Outer>,
Outer: AsRef<T> + AsMut<T> + From<T>,
[src]
T: From<Outer>,
Outer: AsRef<T> + AsMut<T> + From<T>,
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]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
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]
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
[src]
T: UncheckedFrom<S>,
pub fn unchecked_into(self) -> T
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,