[][src]Function wit_text::parse_str

pub fn parse_str(wat: impl AsRef<str>) -> Result<Vec<u8>, Error>

Parses an in-memory string as the text format, returning the file as a binary WebAssembly file.

This function is intended to be a stable convenience function for parsing a *.wat file into a WebAssembly binary. This is a high-level operation which does not expose any parsing internals, for that you'll want to use the Module type and the wast crate.

Errors

This function can fail for a number of reasons, including (but not limited to):

  • The wat input may fail to lex, such as having invalid tokens or syntax
  • The wat input may fail to parse, such as having incorrect syntactical structure
  • The wat input may contain names that could not be resolved