pub fn decode(bytes: &[u8]) -> Result<Module, DecodeError>Expand description
Decodes a module with the default Limits.
§Errors
A DecodeError with the byte offset and the reason when the input is
not a well-formed module of this format version.
§Examples
use bytecode_lang::{decode, encode, DecodeErrorKind, ModuleBuilder};
let module = ModuleBuilder::new().finish().unwrap();
let bytes = encode(&module);
assert_eq!(decode(&bytes).unwrap(), module);
let truncated = &bytes[..bytes.len() - 1];
assert_eq!(decode(truncated).unwrap_err().kind(), &DecodeErrorKind::UnexpectedEnd);