pub fn preprocess(&self, module_bytes: &[u8]) -> Result<Module, PreprocessingError> {
        let module = deserialize(module_bytes)?;

        if memory_section(&module).is_none() {
            // `pwasm_utils::externalize_mem` expects a memory section to exist in the module, and
            // panics otherwise.
            return Err(PreprocessingError::MissingMemorySection);
        }

        let module = pwasm_utils::externalize_mem(module, None, self.wasm_config.max_memory);
        let module = pwasm_utils::inject_gas_counter(
            module,
            &self.wasm_config.opcode_costs().to_set(),
            DEFAULT_GAS_MODULE_NAME,
        )
        .map_err(|_| PreprocessingError::OperationForbiddenByGasRules)?;
        let module = stack_height::inject_limiter(module, self.wasm_config.max_stack_height)
            .map_err(|_| PreprocessingError::StackLimiter)?;
        Ok(module)
    }
/// Preprocesses Wasm bytes and returns a module.
///
/// This process consists of a few steps:
/// - Validate that the given bytes contain a memory section, and check the memory page limit.
/// - Inject gas counters into the code, which makes it possible for the executed Wasm to be
///   charged for opcodes; this also validates opcodes and ensures that there are no forbidden
///   opcodes in use, such as floating point opcodes.
/// - Ensure that the code has a maximum stack height.
///
/// In case the preprocessing rules can't be applied, an error is returned.
/// Otherwise, this method returns a valid module ready to be executed safely on the host.
Preprocesses Wasm bytes and returns a module.
This process consists of a few steps:
Validate that the given bytes contain a memory section, and check the memory page limit.
Inject gas counters into the code, which makes it possible for the executed Wasm to be
charged for opcodes; this also validates opcodes and ensures that there are no forbidden
opcodes in use, such as floating point opcodes.
Ensure that the code has a maximum stack height.

In case the preprocessing rules can't be applied, an error is returned.
Otherwise, this method returns a valid module ready to be executed safely on the host.
Preprocesses Wasm bytes and returns a module . This process consists of a few steps : Validate that the given bytes contain a memory section and check the memory page limit . Inject gas counters into the code which makes it possible for the executed Wasm to be charged for opcodes ; this also validates opcodes and ensures that there are no forbidden opcodes in use such as floating point opcodes . Ensure that the code has a maximum stack height . In case the preprocessing rules can ' t be applied an error is returned . Otherwise this method returns a valid module ready to be executed safely on the host .
pub fn preprocess(&self, module_bytes: &[u8]) -> Result<Module, PreprocessingError> {
        let module = deserialize(module_bytes)?;
        if memory_section(&module).is_none() {
            // `pwasm_utils::externalize_mem` expects a memory section to exist in the module, and
            // panics otherwise.
            return Err(PreprocessingError::MissingMemorySection);
        }
        let module = pwasm_utils::externalize_mem(module, None, self.wasm_config.max_memory);
        let module = pwasm_utils::inject_gas_counter(
            module,
            &self.wasm_config.opcode_costs().to_set(),
            DEFAULT_GAS_MODULE_NAME,
        )
        .map_err(|_| PreprocessingError::OperationForbiddenByGasRules)?;
        let module = stack_height::inject_limiter(module, self.wasm_config.max_stack_height)
            .map_err(|_| PreprocessingError::StackLimiter)?;
        Ok(module)
    }
pub fn preprocess ( & self , module_bytes : & [ u8 ] ) -> Result < Module , PreprocessingError > { let module = deserialize ( module_bytes ) ? ; if memory_section ( & module ) . is_none ( ) { // `pwasm_utils::externalize_mem` expects a memory section to exist in the module, and // panics otherwise. return Err ( PreprocessingError :: MissingMemorySection ) ; } let module = pwasm_utils :: externalize_mem ( module , None , self . wasm_config . max_memory ) ; let module = pwasm_utils :: inject_gas_counter ( module , & self . wasm_config . opcode_costs ( ) . to_set ( ) , DEFAULT_GAS_MODULE_NAME , ) . map_err ( | _ | PreprocessingError :: OperationForbiddenByGasRules ) ? ; let module = stack_height :: inject_limiter ( module , self . wasm_config . max_stack_height ) . map_err ( | _ | PreprocessingError :: StackLimiter ) ? ; Ok ( module ) }
Preprocesses Wasm bytes and returns a module.
Preprocesses Wasm bytes and returns a module .
&self
module_bytes
&[u8]
&self
module_bytes
&[u8]