/// Validates a Wasm binary against the requirements of the interface spec
/// defined in https://sdk.dfinity.org/docs/interface-spec/index.html.
///
/// It constructs a module by parsing the input Wasm binary and then calls into
/// more specific methods that validate different sections of the Wasm binary.
/// Currently, the sections we verify are:
/// * Import
/// * Export
/// * Code
/// * Data
/// * Global
/// * Function
/// * CustomSections
///
/// Additionally, it ensures that the wasm binary can actually compile.


It constructs a module by parsing the input Wasm binary and then calls into
more specific methods that validate different sections of the Wasm binary.
Currently, the sections we verify are:
Import
Export
Code
Data
Global
Function
CustomSections

Additionally, it ensures that the wasm binary can actually compile.
It constructs a module by parsing the input Wasm binary and then calls into more specific methods that validate different sections of the Wasm binary . Currently the sections we verify are : Import Export Code Data Global Function CustomSections Additionally it ensures that the wasm binary can actually compile .
pub fn validate_wasm_binary(
    wasm: &BinaryEncodedWasm,
    config: &EmbeddersConfig,
) -> Result<WasmValidationDetails, WasmValidationError> {
    can_compile(wasm)?;
    let module = parity_wasm::deserialize_buffer::<Module>(wasm.as_slice())
        .map_err(|err| WasmValidationError::ParityDeserializeError(into_parity_wasm_error(err)))?;
    let imports_details = validate_import_section(&module, &config.feature_flags)?;
    let reserved_exports = validate_export_section(&module)?;
    validate_data_section(&module)?;
    validate_global_section(&module, config.max_globals)?;
    validate_function_section(&module, config.max_functions)?;
    let wasm_metadata = validate_custom_section(&module, config)?;
    Ok(WasmValidationDetails {
        reserved_exports,
        imports_details,
        wasm_metadata,
    })
}
pub fn validate_wasm_binary ( wasm : & BinaryEncodedWasm , config : & EmbeddersConfig , ) -> Result < WasmValidationDetails , WasmValidationError > { can_compile ( wasm ) ? ; let module = parity_wasm :: deserialize_buffer :: < Module > ( wasm . as_slice ( ) ) . map_err ( | err | WasmValidationError :: ParityDeserializeError ( into_parity_wasm_error ( err ) ) ) ? ; let imports_details = validate_import_section ( & module , & config . feature_flags ) ? ; let reserved_exports = validate_export_section ( & module ) ? ; validate_data_section ( & module ) ? ; validate_global_section ( & module , config . max_globals ) ? ; validate_function_section ( & module , config . max_functions ) ? ; let wasm_metadata = validate_custom_section ( & module , config ) ? ; Ok ( WasmValidationDetails { reserved_exports , imports_details , wasm_metadata , } ) }
Validates a Wasm binary against the requirements of the interface spec
defined in https://sdk.dfinity.org/docs/interface-spec/index.html.
Validates a Wasm binary against the requirements of the interface spec defined in https : // sdk . dfinity . org / docs / interface - spec / index . html .
wasm
&BinaryEncodedWasm
config
&EmbeddersConfig