[−][src]Function wasmer_interface_types_fl::decoders::wat::parse
pub fn parse<'input>(input: &'input Buffer<'_>) -> Result<Interfaces<'input>>
Parse a WIT definition in its textual format, and produces an
AST with the Interfaces
structure upon succesful.
Examples
use wasmer_interface_types::{ ast::{Adapter, Export, Implementation, Import, Interfaces, Type}, decoders::wat::{parse, Buffer}, interpreter::Instruction, types::InterfaceType, }; let input = Buffer::new( r#"(@interface type (func (param i32) (result s8))) (@interface import "ns" "foo" (func (type 0))) (@interface func (type 0) arg.get 42) (@interface export "bar" (func 0)) (@interface implement (func 0) (func 1))"#, ) .unwrap(); let output = 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, }], }; assert_eq!(parse(&input).unwrap(), output);