/// Callback for the `ModuleConfig::on_parse` function in `walrus` to act as a
/// convenience to parse the wasm interface types custom section, if present.
Callback for the `ModuleConfig::on_parse` function in `walrus` to act as a
convenience to parse the wasm interface types custom section, if present.
Callback for the ` ModuleConfig :: on_parse ` function in ` walrus ` to act as a convenience to parse the wasm interface types custom section if present .
pub fn on_parse(module: &mut Module, ids: &IndicesToIds) -> Result<()> {
    let section = match module.customs.remove_raw(SECTION_NAME) {
        Some(s) => s,
        None => return Ok(()),
    };
    let mut parser = wit_parser::Parser::new(0, &section.data)
        .context("failed parsing wasm interface types header")?;
    let mut section = WasmInterfaceTypes::default();
    let mut wids = WitIndicesToIds::default();
    while !parser.is_empty() {
        let s = parser
            .section()
            .context("failed parsing wasm interface types section header")?;
        match s {
            wit_parser::Section::Type(t) => section.parse_types(t, &mut wids)?,
            wit_parser::Section::Import(t) => section.parse_imports(t, &mut wids)?,
            wit_parser::Section::Func(t) => section.parse_funcs(t, ids, &mut wids)?,
            wit_parser::Section::Implement(t) => section.parse_implements(t, ids, &mut wids)?,
            wit_parser::Section::Export(t) => section.parse_exports(t, &mut wids)?,
        }
    }
    module.customs.add(section);
    Ok(())
}
pub fn on_parse ( module : & mut Module , ids : & IndicesToIds ) -> Result < ( ) > { let section = match module . customs . remove_raw ( SECTION_NAME ) { Some ( s ) => s , None => return Ok ( ( ) ) , } ; let mut parser = wit_parser :: Parser :: new ( 0 , & section . data ) . context ( " " ) ? ; let mut section = WasmInterfaceTypes :: default ( ) ; let mut wids = WitIndicesToIds :: default ( ) ; while ! parser . is_empty ( ) { let s = parser . section ( ) . context ( " " ) ? ; match s { wit_parser :: Section :: Type ( t ) => section . parse_types ( t , & mut wids ) ? , wit_parser :: Section :: Import ( t ) => section . parse_imports ( t , & mut wids ) ? , wit_parser :: Section :: Func ( t ) => section . parse_funcs ( t , ids , & mut wids ) ? , wit_parser :: Section :: Implement ( t ) => section . parse_implements ( t , ids , & mut wids ) ? , wit_parser :: Section :: Export ( t ) => section . parse_exports ( t , & mut wids ) ? , } } module . customs . add ( section ) ; Ok ( ( ) ) }
Callback for the `ModuleConfig::on_parse` function in `walrus` to act as a
convenience to parse the wasm interface types custom section, if present.
Callback for the ` ModuleConfig :: on_parse ` function in ` walrus ` to act as a convenience to parse the wasm interface types custom section if present .
module
&mut Module
ids
&IndicesToIds