[−][src]Module wasmer_interface_types_fl::encoders::wat
Writes the AST into a string representing WIT with its textual format.
Example
use wasmer_interface_types::{ ast::{Adapter, Export, Implementation, Import, Interfaces, Type}, encoders::wat::*, interpreter::Instruction, types::InterfaceType, }; let input: String = (&Interfaces { types: vec![Type::Function { inputs: vec![InterfaceType::I32], outputs: vec![InterfaceType::S8], }], imports: vec![Import { namespace: "ns", name: "foo", function_type: 0, }], adapters: vec![Adapter { function_type: 0, instructions: vec![Instruction::ArgumentGet { index: 42 }], }], exports: vec![Export { name: "bar", function_type: 0, }], implementations: vec![Implementation { core_function_type: 0, adapter_function_type: 1, }], }) .to_string(); let output = r#";; Types (@interface type (func (param i32) (result s8))) ;; Imports (@interface import "ns" "foo" (func (type 0))) ;; Adapters (@interface func (type 0) arg.get 42) ;; Exports (@interface export "bar" (func 0)) ;; Implementations (@interface implement (func 0) (func 1))"#; assert_eq!(input, output);