Enum wai_bindgen_gen_core::Direction
source · 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.