pub struct Function<'a> {
pub kind: FunctionKind<'a>,
pub name: &'a str,
pub externrefs: BitSlice<'a>,
}
Expand description
Information about a function with Resource
args or return type.
This information is written to a custom section of a WASM module and is then used during module post-processing.
Fields§
§kind: FunctionKind<'a>
Kind of this function.
name: &'a str
Name of this function.
externrefs: BitSlice<'a>
Bit slice marking Resource
args / return type.
Implementations§
source§impl<'a> Function<'a>
impl<'a> Function<'a>
sourcepub const CUSTOM_SECTION_NAME: &'static str = "__externrefs"
pub const CUSTOM_SECTION_NAME: &'static str = "__externrefs"
Name of a custom section in WASM modules where Function
declarations are stored.
Function
s can be read from this section using Self::read_from_section()
.
sourcepub fn read_from_section(buffer: &mut &'a [u8]) -> Result<Self, ReadError>
pub fn read_from_section(buffer: &mut &'a [u8]) -> Result<Self, ReadError>
Reads function information from a WASM custom section. After reading, the buffer
is advanced to trim the bytes consumed by the parser.
This crate does not provide tools to read custom sections from a WASM module;
use a library like walrus
or wasmparser
for this purpose.
Errors
Returns an error if the custom section is malformed.