/// Convenience function to validate a single [`Payload`].
///
/// This function is intended to be used as a convenience. It will
/// internally perform any validation necessary to validate the [`Payload`]
/// provided. The convenience part is that you're likely already going to
/// be matching on [`Payload`] in your application, at which point it's more
/// appropriate to call the individual methods on [`Validator`] per-variant
/// in [`Payload`], such as [`Validator::type_section`].
///
/// This function returns a [`ValidPayload`] variant on success, indicating
/// one of a few possible actions that need to be taken after a payload is
/// validated. For example function contents are not validated here, they're
/// returned through [`ValidPayload`] for validation by the caller.
Convenience function to validate a single [`Payload`].
This function is intended to be used as a convenience. It will
internally perform any validation necessary to validate the [`Payload`]
provided.

This function returns a [`ValidPayload`] variant on success, indicating
one of a few possible actions that need to be taken after a payload is
validated. For example function contents are not validated here, they're
returned through [`ValidPayload`] for validation by the caller.
Convenience function to validate a single [ ` Payload ` ] . This function is intended to be used as a convenience . It will internally perform any validation necessary to validate the [ ` Payload ` ] provided . This function returns a [ ` ValidPayload ` ] variant on success indicating one of a few possible actions that need to be taken after a payload is validated . For example function contents are not validated here they ' re returned through [ ` ValidPayload ` ] for validation by the caller .
pub fn payload<'a>(&mut self, payload: &Payload<'a>) -> Result<ValidPayload<'a>> {
        use crate::Payload::*;
        match payload {
            Version { num, range } => self.version(*num, range)?,
            TypeSection(s) => self.type_section(s)?,
            ImportSection(s) => self.import_section(s)?,
            AliasSection(s) => self.alias_section(s)?,
            InstanceSection(s) => self.instance_section(s)?,
            ModuleSection(s) => self.module_section(s)?,
            FunctionSection(s) => self.function_section(s)?,
            TableSection(s) => self.table_section(s)?,
            MemorySection(s) => self.memory_section(s)?,
            GlobalSection(s) => self.global_section(s)?,
            ExportSection(s) => self.export_section(s)?,
            StartSection { func, range } => self.start_section(*func, range)?,
            ElementSection(s) => self.element_section(s)?,
            DataCountSection { count, range } => self.data_count_section(*count, range)?,
            CodeSectionStart {
                count,
                range,
                size: _,
            } => self.code_section_start(*count, range)?,
            CodeSectionEntry(body) => {
                let func_validator = self.code_section_entry()?;
                return Ok(ValidPayload::Func(func_validator, body.clone()));
            }
            ModuleCodeSectionStart {
                count,
                range,
                size: _,
            } => self.module_code_section_start(*count, range)?,
            DataSection(s) => self.data_section(s)?,
            End => {
                self.end()?;
                return Ok(if self.state.depth > 0 {
                    ValidPayload::Pop
                } else {
                    ValidPayload::Ok
                });
            }
            CustomSection { .. } => {} // no validation for custom sections
            UnknownSection { id, range, .. } => self.unknown_section(*id, range)?,
            ModuleCodeSectionEntry { parser, range: _ } => {
                let subvalidator = self.module_code_section_entry();
                return Ok(ValidPayload::Push(parser.clone(), subvalidator));
            }
        }
        Ok(ValidPayload::Ok)
    }
pub fn payload < ' a > ( & mut self , payload : & Payload < ' a > ) -> Result < ValidPayload < ' a > > { use crate :: Payload :: * ; match payload { Version { num , range } => self . version ( * num , range ) ? , TypeSection ( s ) => self . type_section ( s ) ? , ImportSection ( s ) => self . import_section ( s ) ? , AliasSection ( s ) => self . alias_section ( s ) ? , InstanceSection ( s ) => self . instance_section ( s ) ? , ModuleSection ( s ) => self . module_section ( s ) ? , FunctionSection ( s ) => self . function_section ( s ) ? , TableSection ( s ) => self . table_section ( s ) ? , MemorySection ( s ) => self . memory_section ( s ) ? , GlobalSection ( s ) => self . global_section ( s ) ? , ExportSection ( s ) => self . export_section ( s ) ? , StartSection { func , range } => self . start_section ( * func , range ) ? , ElementSection ( s ) => self . element_section ( s ) ? , DataCountSection { count , range } => self . data_count_section ( * count , range ) ? , CodeSectionStart { count , range , size : _ , } => self . code_section_start ( * count , range ) ? , CodeSectionEntry ( body ) => { let func_validator = self . code_section_entry ( ) ? ; return Ok ( ValidPayload :: Func ( func_validator , body . clone ( ) ) ) ; } ModuleCodeSectionStart { count , range , size : _ , } => self . module_code_section_start ( * count , range ) ? , DataSection ( s ) => self . data_section ( s ) ? , End => { self . end ( ) ? ; return Ok ( if self . state . depth > 0 { ValidPayload :: Pop } else { ValidPayload :: Ok } ) ; } CustomSection { .. } => { } // no validation for custom sections UnknownSection { id , range , .. } => self . unknown_section ( * id , range ) ? , ModuleCodeSectionEntry { parser , range : _ } => { let subvalidator = self . module_code_section_entry ( ) ; return Ok ( ValidPayload :: Push ( parser . clone ( ) , subvalidator ) ) ; } } Ok ( ValidPayload :: Ok ) }
Convenience function to validate a single [`Payload`].
Convenience function to validate a single [ ` Payload ` ] .
&mut self
payload
&Payload<'a>