pub enum Direction {
    Import,
    Export,
}
Expand description

This is the direction from the user’s perspective. Are we importing functions to call, or defining functions and exporting them to be called?

This is only used outside of Generator implementations. Inside of Generator implementations, the Direction is translated to an AbiVariant instead. The ABI variant is usually the same as the Direction, but it’s different in the case of the Wasmtime host bindings:

In a wasm-calling-wasm use case, one wasm module would use the Import ABI, the other would use the Export ABI, and there would be an adapter layer between the two that translates from one ABI to the other.

But with wasm-calling-host, we don’t go through a separate adapter layer; the binding code we generate on the host side just does everything itself. So when the host is conceptually “exporting” a function to wasm, it uses the Import ABI so that wasm can also use the Import ABI and import it directly from the host.

These are all implementation details; from the user perspective, and from the perspective of everything outside of Generator implementations, export means I’m exporting functions to be called, and import means I’m importing functions that I’m going to call, in both wasm modules and host code. The enum here represents this user perspective.

Variants

Import

Export

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. 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

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 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

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.