#[non_exhaustive]
pub enum TrapCode {
    StackOverflow,
    MemoryOutOfBounds,
    HeapMisaligned,
    TableOutOfBounds,
    IndirectCallToNull,
    BadSignature,
    IntegerOverflow,
    IntegerDivisionByZero,
    BadConversionToInteger,
    UnreachableCodeReached,
    Interrupt,
    AlwaysTrapAdapter,
}
Expand description

A trap code describing the reason for a trap.

All trap instructions have an explicit trap code.

The code can be accessed from the c-api, where the possible values are translated into enum values defined there:

  • wasm_trap_code in c-api/src/trap.rs, and
  • wasmtime_trap_code_enum in c-api/include/wasmtime/trap.h.

These need to be kept in sync.

Variants (Non-exhaustive)

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.

StackOverflow

The current stack space was exhausted.

MemoryOutOfBounds

An out-of-bounds memory access.

HeapMisaligned

A wasm atomic operation was presented with a not-naturally-aligned linear-memory address.

TableOutOfBounds

An out-of-bounds access to a table.

IndirectCallToNull

Indirect call to a null table entry.

BadSignature

Signature mismatch on indirect call.

IntegerOverflow

An integer arithmetic operation caused an overflow.

IntegerDivisionByZero

An integer division by zero.

BadConversionToInteger

Failed float-to-int conversion.

UnreachableCodeReached

Code that was supposed to have been unreachable was reached.

Interrupt

Execution has potentially run too long and may be interrupted.

AlwaysTrapAdapter

When the component-model feature is enabled this trap represents a function that was canon lift’d, then canon lower’d, then called. This combination of creation of a function in the component model generates a function that always traps and, when called, produces this flavor of trap.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.