fn load_constant(cursor: &mut Cursor<&[u8]>) -> BinaryLoaderResult<Constant> {
    let type_ = load_signature_token(cursor)?;
    let size = read_uleb_u32_internal(cursor)? as usize;
    if size > std::u16::MAX as usize {
        return Err(
            VMStatus::new(StatusCode::MALFORMED).with_message("Bad Constant data size".to_string())
        );
    }
    let mut data: Vec<u8> = vec![0u8; size];
    let count = cursor.read(&mut data).map_err(|_| {
        VMStatus::new(StatusCode::MALFORMED).with_message("Unexpected end of table".to_string())
    })?;
    if count != size {
        return Err(
            VMStatus::new(StatusCode::MALFORMED).with_message("Bad Constant data size".to_string())
        );
    }
    Ok(Constant { type_, data })
}
/// Build a single `Constant`
Build a single `Constant`
Build a single ` Constant `
fn load_constant(cursor: &mut Cursor<&[u8]>) -> BinaryLoaderResult<Constant> {
    let type_ = load_signature_token(cursor)?;
    let size = read_uleb_u32_internal(cursor)? as usize;
    if size > std::u16::MAX as usize {
        return Err(
            VMStatus::new(StatusCode::MALFORMED).with_message("Bad Constant data size".to_string())
        );
    }
    let mut data: Vec<u8> = vec![0u8; size];
    let count = cursor.read(&mut data).map_err(|_| {
        VMStatus::new(StatusCode::MALFORMED).with_message("Unexpected end of table".to_string())
    })?;
    if count != size {
        return Err(
            VMStatus::new(StatusCode::MALFORMED).with_message("Bad Constant data size".to_string())
        );
    }
    Ok(Constant { type_, data })
}
fn load_constant ( cursor : & mut Cursor < & [ u8 ] > ) -> BinaryLoaderResult < Constant > { let type_ = load_signature_token ( cursor ) ? ; let size = read_uleb_u32_internal ( cursor ) ? as usize ; if size > std :: u16 :: MAX as usize { return Err ( VMStatus :: new ( StatusCode :: MALFORMED ) . with_message ( " " . to_string ( ) ) ) ; } let mut data : Vec < u8 > = vec ! [ 0u8 size ] ; let count = cursor . read ( & mut data ) . map_err ( | _ | { VMStatus :: new ( StatusCode :: MALFORMED ) . with_message ( " " . to_string ( ) ) } ) ? ; if count != size { return Err ( VMStatus :: new ( StatusCode :: MALFORMED ) . with_message ( " " . to_string ( ) ) ) ; } Ok ( Constant { type_ , data } ) }
Build a single `Constant`
Build a single ` Constant `
cursor
&mut Cursor<&[u8]>
cursor
&mut Cursor<&[u8]>