pub fn encode_interface_component(interface: &Interface) -> Result<Vec<u8>> {
    let mut types = ComponentTypeSection::new();
    let mut exports = ComponentExportSection::new();
    let mut type_map = HashMap::new();
    let mut func_type_map = HashMap::new();
    let mut exported = HashMap::new();

    let mut encoder = InterfaceEncoder::new(
        interface,
        &mut types,
        &mut exports,
        &mut type_map,
        &mut func_type_map,
        &mut exported,
    )?;
    encoder.encode(true /* export the function types */)?;

    let mut component = Component::new();
    component.section(&types);
    component.section(&exports);
    let output = component.finish();

    let mut validator = Validator::new();
    validator.wasm_features(WasmFeatures {
        component_model: true,
        ..Default::default()
    });

    validator
        .validate_all(&output)
        .context("failed to validate component output")?;

    Ok(output)
}
/// Encodes an "interface-only" component from an interface definition file.
///
/// The resulting component file will only describe the types of the given interface.
Encodes an "interface-only" component from an interface definition file.
The resulting component file will only describe the types of the given interface.
Encodes an " interface - only " component from an interface definition file . The resulting component file will only describe the types of the given interface .
pub fn encode_interface_component(interface: &Interface) -> Result<Vec<u8>> {
    let mut types = ComponentTypeSection::new();
    let mut exports = ComponentExportSection::new();
    let mut type_map = HashMap::new();
    let mut func_type_map = HashMap::new();
    let mut exported = HashMap::new();
    let mut encoder = InterfaceEncoder::new(
        interface,
        &mut types,
        &mut exports,
        &mut type_map,
        &mut func_type_map,
        &mut exported,
    )?;
    encoder.encode(true /* export the function types */)?;
    let mut component = Component::new();
    component.section(&types);
    component.section(&exports);
    let output = component.finish();
    let mut validator = Validator::new();
    validator.wasm_features(WasmFeatures {
        component_model: true,
        ..Default::default()
    });
    validator
        .validate_all(&output)
        .context("failed to validate component output")?;
    Ok(output)
}
pub fn encode_interface_component ( interface : & Interface ) -> Result < Vec < u8 > > { let mut types = ComponentTypeSection :: new ( ) ; let mut exports = ComponentExportSection :: new ( ) ; let mut type_map = HashMap :: new ( ) ; let mut func_type_map = HashMap :: new ( ) ; let mut exported = HashMap :: new ( ) ; let mut encoder = InterfaceEncoder :: new ( interface , & mut types , & mut exports , & mut type_map , & mut func_type_map , & mut exported , ) ? ; encoder . encode ( true /* export the function types */ ) ? ; let mut component = Component :: new ( ) ; component . section ( & types ) ; component . section ( & exports ) ; let output = component . finish ( ) ; let mut validator = Validator :: new ( ) ; validator . wasm_features ( WasmFeatures { component_model : true , .. Default :: default ( ) } ) ; validator . validate_all ( & output ) . context ( " " ) ? ; Ok ( output ) }
Encodes an "interface-only" component from an interface definition file.
Encodes an " interface - only " component from an interface definition file .
interface
&Interface
interface
&Interface