fn load_struct_defs(
    binary: &[u8],
    table: &Table,
    struct_defs: &mut Vec<StructDefinition>,
) -> BinaryLoaderResult<()> {
    let start = table.offset as usize;
    let end = start + table.count as usize;
    let mut cursor = Cursor::new(&binary[start..end]);
    while cursor.position() < u64::from(table.count) {
        let struct_handle = read_uleb_u16_internal(&mut cursor)?;
        let field_information_flag = match cursor.read_u8() {
            Ok(byte) => SerializedNativeStructFlag::from_u8(byte)?,
            Err(_) => {
                return Err(VMStatus::new(StatusCode::MALFORMED)
                    .with_message("Invalid field info in struct".to_string()))
            }
        };
        let field_information = match field_information_flag {
            SerializedNativeStructFlag::NATIVE => StructFieldInformation::Native,
            SerializedNativeStructFlag::DECLARED => {
                let fields = load_field_defs(&mut cursor)?;
                StructFieldInformation::Declared(fields)
            }
        };
        struct_defs.push(StructDefinition {
            struct_handle: StructHandleIndex(struct_handle),
            field_information,
        });
    }
    Ok(())
}
/// Builds the `StructDefinition` table.
Builds the `StructDefinition` table.
Builds the ` StructDefinition ` table .
fn load_struct_defs(
    binary: &[u8],
    table: &Table,
    struct_defs: &mut Vec<StructDefinition>,
) -> BinaryLoaderResult<()> {
    let start = table.offset as usize;
    let end = start + table.count as usize;
    let mut cursor = Cursor::new(&binary[start..end]);
    while cursor.position() < u64::from(table.count) {
        let struct_handle = read_uleb_u16_internal(&mut cursor)?;
        let field_information_flag = match cursor.read_u8() {
            Ok(byte) => SerializedNativeStructFlag::from_u8(byte)?,
            Err(_) => {
                return Err(VMStatus::new(StatusCode::MALFORMED)
                    .with_message("Invalid field info in struct".to_string()))
            }
        };
        let field_information = match field_information_flag {
            SerializedNativeStructFlag::NATIVE => StructFieldInformation::Native,
            SerializedNativeStructFlag::DECLARED => {
                let fields = load_field_defs(&mut cursor)?;
                StructFieldInformation::Declared(fields)
            }
        };
        struct_defs.push(StructDefinition {
            struct_handle: StructHandleIndex(struct_handle),
            field_information,
        });
    }
    Ok(())
}
fn load_struct_defs ( binary : & [ u8 ] , table : & Table , struct_defs : & mut Vec < StructDefinition > , ) -> BinaryLoaderResult < ( ) > { let start = table . offset as usize ; let end = start + table . count as usize ; let mut cursor = Cursor :: new ( & binary [ start .. end ] ) ; while cursor . position ( ) < u64 :: from ( table . count ) { let struct_handle = read_uleb_u16_internal ( & mut cursor ) ? ; let field_information_flag = match cursor . read_u8 ( ) { Ok ( byte ) => SerializedNativeStructFlag :: from_u8 ( byte ) ? , Err ( _ ) => { return Err ( VMStatus :: new ( StatusCode :: MALFORMED ) . with_message ( " " . to_string ( ) ) ) } } ; let field_information = match field_information_flag { SerializedNativeStructFlag :: NATIVE => StructFieldInformation :: Native , SerializedNativeStructFlag :: DECLARED => { let fields = load_field_defs ( & mut cursor ) ? ; StructFieldInformation :: Declared ( fields ) } } ; struct_defs . push ( StructDefinition { struct_handle : StructHandleIndex ( struct_handle ) , field_information , } ) ; } Ok ( ( ) ) }
Builds the `StructDefinition` table.
Builds the ` StructDefinition ` table .
binary
&[u8]
table
&Table
struct_defs
&mut Vec<StructDefinition>
binary
&[u8]
table
&Table
struct_defs
&mut Vec<StructDefinition>