use crate::limits::{MAX_WASM_FUNCTION_RETURNS, MAX_WASM_START_ARGS};
use crate::{BinaryReader, FromReader, Result};
#[derive(Debug, Clone)]
pub struct ComponentStartFunction {
pub func_index: u32,
pub arguments: Box<[u32]>,
pub results: u32,
}
impl<'a> FromReader<'a> for ComponentStartFunction {
fn from_reader(reader: &mut BinaryReader<'a>) -> Result<Self> {
let func_index = reader.read_var_u32()?;
let arguments = reader
.read_iter(MAX_WASM_START_ARGS, "start function arguments")?
.collect::<Result<_>>()?;
let results = reader.read_size(MAX_WASM_FUNCTION_RETURNS, "start function results")? as u32;
Ok(ComponentStartFunction {
func_index,
arguments,
results,
})
}
}