# Type mapping
| G-- | guest side |
| H-- | host side |
| -I- | guest-import (guest calls) |
| -E- | guest-export (host calls) |
| --A | argument |
| --R | result |
| --S | in struct |
| v | passed by value |
| t | owernership transferred |
| p | cabi_post_ cleans up |
| 🌓 | asymmetric | | 📘 | canonical |
| ⚖️ | symmetric | | 🪞 | symmetric |
| GIA | v | string | &str | string_view (17) | addr, len | |
| | | list | &[T] | std::span | addr, len | |
| | | tuple | (...) | std::tuple | 0, 1, ...| |
| | | tuple<string, list> | (&str, &[T]) | std::tuple<...> | a,l,a,l |
| | | record{string, list} | &T | T const& | a,l,a,l |
| | | large-struct (>16 args) | &T | T const& | &t |
| | | result<string,list> | Result<&str, &[]> | std::expected<string_view, span> | d,a,l |
| | | option\<string> | Option\<&str> | optional<string_view> const& | d,a,l|
| | | list\<resrc> | &[\&Resrc]? | vector<string_view> const& | a,l|
| GIR | t | string | String | wit::string | &(addr, len) | |
| | | list | Vec | wit::vector | &(a,l) |
| | | result<string,list> | Result<String, Vec> | std::expected<wit::string, wit::vector> | &(d,a,l) |
| GEA | t | string | String | 🌓 wit::string | addr, len |
| | | | | ⚖️ string_view | |
| | | result<string,list> | Result<String, Vec> | 🌓 std::expected<wit::string, wit::vector> | d,a,l |
| | | | | ⚖️ std::expected<string_view, wit::span> | |
| GER | p | string | String | wit::string (or std?) | 📘 -> &(a,l) cabi_post_N:P/I#F |
| | | | | | 🪞 &(a,l) |
| | | result<string,list> | Result<String, Vec> | std::expected<wit::string, wit::vector> | 📘 -> &(d,a,l) cabi_post |
| --S | ? | string | String | wit::string | addr, len |
| HIA | v | string | | string_view | a,l |
| HIR | t | string | | wit::string | &(a,l) |
| HEA | t | string | | 🌓 wit::string | a,l |
| | | | | ⚖️ string_view | |
| HER | p | string | | 🌓 wit::guest_owned<string_view> | 📘 -> &(a,l) |
| | | | | ⚖️ wit::string | 🪞 &(a,l) |
On the host a wit::string can be constructed(=allocated) with an exec_env argument. Thus, without an exec_env a wit::string on the host is inaccessible.
Complex (non-POD) struct elements on the host will need exec_env to decode or construct.
## [Symmetric ABI](https://github.com/WebAssembly/component-model/issues/386)
The idea is to directly connect (link) components to each other.
Thus imported and exported functions and resources need to be compatible
at the ABI level.
For now for functions the guest import convention is used in both directions:
- The imported function ABI is used with the following properties
- (unchanged) List and string arguments are passed as Views, no free
required, lifetime is constrained until the end of the call
- (unchanged) Owned resources in arguments or results pass ownership
to the callee
- (unchanged) If there are too many (>1) flat results, a local
uninitialized ret_area is passed via the last argument
- (unchanged) Returned objects are owned.
For functional safety, i.e. avoiding all
allocations in the hot path, the hope is with [#385](https://github.com/WebAssembly/component-model/issues/385).
- The imported resource ABI is used also for exporting
with one modification:
Resource IDs become usize, so you can optimize the resource table away.