//! A crate to parse the textual format for WebAssembly interface types.
//!
//! This crate is a work-in-progress and should expect to have a good deal of
//! change as the official proposal evolves. The main purpose of this crate is
//! to parse a textual file into a binary representation, and the parsing
//! includes parsing of all of the WebAssembly core types/syntax as well.
use ;
use Cow;
use Path;
use str;
use ParseBuffer;
pub use *;
/// Parses a `file` on the filesystem as a textual representation of WebAssembly
/// Interface Types, returning the binary representation of the module.
///
/// Note that the `file` could either be a valid `*.wat` or `*.wasm`
/// file. In the `*.wasm` case the bytes are passed through unmodified.
///
/// # Errors
///
/// For information about errors, see the [`parse_bytes`] documentation.
/// Parses in-memory bytes as either the text format or a binary WebAssembly
/// module.
///
/// This function will attempt to interpret the given bytes as one of two
/// options:
///
/// * A utf-8 string which is a `*.wat` file to be parsed.
/// * A binary WebAssembly file starting with `b"\0asm"`
///
/// If the input is a string then it will be parsed as `*.wat`, and then after
/// parsing it will be encoded back into a WebAssembly binary module. If the
/// input is a binary that starts with `b"\0asm"` it will be returned verbatim.
/// Everything that doesn't start with `b"\0asm"` will be parsed as a utf-8
/// `*.wat` file, returning errors as appropriate.
///
/// # Errors
///
/// In addition to all of the errors that can be returned from [`parse_str`],
/// this function will also return an error if the input does not start with
/// `b"\0asm"` and is invalid utf-8. (failed to even try to call [`parse_str`]).
/// 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
///