# [−] [src] Enum wasmi::TrapKind

    pub enum TrapKind {
        Unreachable,
        MemoryAccessOutOfBounds,
        TableAccessOutOfBounds,
        ElemUninitialized,
        DivisionByZero,
        InvalidConversionToInt,
        StackOverflow,
        UnexpectedSignature,
        Host(Box<dyn HostError>),
    }

Error type which can be thrown by wasm code or by host environment.

See `Trap` for details.

## Variants

`Unreachable`

Wasm code executed `unreachable` opcode.

`unreachable` is a special opcode which always traps upon execution. This opcode have a similar purpose as `ud2` in x86.

`MemoryAccessOutOfBounds`

Attempt to load or store at the address which lies outside of bounds of the memory.

Since addresses are interpreted as unsigned integers, out of bounds access can't happen with negative addresses (i.e. they will always wrap).

`TableAccessOutOfBounds`

Attempt to access table element at index which lies outside of bounds.

This typically can happen when `call_indirect` is executed with index that lies out of bounds.

Since indexes are interpreted as unsinged integers, out of bounds access can't happen with negative indexes (i.e. they will always wrap).

`ElemUninitialized`

Attempt to access table element which is uninitialized (i.e. `None`).

This typically can happen when `call_indirect` is executed.

`DivisionByZero`

Attempt to divide by zero.

This trap typically can happen if `div` or `rem` is executed with zero as divider.

`InvalidConversionToInt`

Attempt to make a conversion to an int failed.

This can happen when:

- trying to do signed division (or get the remainder) -2N-1 over -1. This is because the result +2N-1 isn't representable as a N-bit signed integer.
- trying to truncate NaNs, infinity, or value for which the result is out of range into an integer.

`StackOverflow`

Stack overflow.

This is likely caused by some infinite or very deep recursion. Extensive inlining might also be the cause of stack overflow.

`UnexpectedSignature`

Attempt to invoke a function with mismatching signature.

This can happen if `FuncInstance` was invoked with mismatching signature.

This can always happen with indirect calls. `call_indirect` instruction always specifies the expected signature of function. If `call_indirect` is executed with index that points on function with signature different that is expected by this `call_indirect`, this trap is raised.

`Host(Box<dyn HostError>)`

Error specified by the host.

Typically returned from an implementation of `Externals`.

## Methods

### `impl TrapKind` [src]

#### `pub fn is_host(&self) -> bool` [src]

Whether this trap is specified by the host.

## Trait Implementations

### `impl From<TrapKind> for Trap` [src]

#### `fn from(e: TrapKind) -> Trap` [src]

Performs the conversion.

### `impl Debug for TrapKind` [src]

#### `fn fmt(&self, f: &mut Formatter) -> Result` [src]

Formats the value using the given formatter. Read more

## Auto Trait Implementations

### `impl Send for TrapKind`

### `impl Sync for TrapKind`

### `impl Unpin for TrapKind`

### `impl !UnwindSafe for TrapKind`

### `impl !RefUnwindSafe for TrapKind`

## Blanket Implementations

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

#### `fn into(self) -> U` [src]

Performs the conversion.

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

#### `fn from(t: T) -> T` [src]

Performs the conversion.

### `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.

#### `fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>` [src]

Performs the conversion.

### `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.

#### `fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>` [src]

Performs the conversion.

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

#### `fn borrow(&self) -> &T` [src]

Immutably borrows from an owned value. Read more

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

#### `fn borrow_mut(&mut self) -> &mut T` [src]

Mutably borrows from an owned value. Read more

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

#### `fn type_id(&self) -> TypeId` [src]

Gets the `TypeId` of `self`. Read more

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)