1- use crate :: HeaderTagType ;
21use crate :: { HeaderTagFlag , MbiTagType } ;
2+ use crate :: { HeaderTagType , MbiTagTypeId } ;
33use core:: fmt;
44use core:: fmt:: { Debug , Formatter } ;
55use core:: marker:: PhantomData ;
66use core:: mem:: size_of;
7+ use multiboot2:: TagType ;
78
89/// Specifies what specific tag types the bootloader should provide
910/// inside the mbi.
@@ -15,14 +16,14 @@ pub struct InformationRequestHeaderTag<const N: usize> {
1516 size : u32 ,
1617 // Length is determined by size.
1718 // Must be parsed during runtime with unsafe pointer magic and the size field.
18- requests : [ MbiTagType ; N ] ,
19+ requests : [ MbiTagTypeId ; N ] ,
1920}
2021
2122impl < const N : usize > InformationRequestHeaderTag < N > {
2223 /// Creates a new object. The size parameter is the value of the size property.
2324 /// It doesn't have to match with `N` necessarily, because during compile time we
2425 /// can't know the size of the tag in all runtime situations.
25- pub fn new ( flags : HeaderTagFlag , requests : [ MbiTagType ; N ] , size : Option < u32 > ) -> Self {
26+ pub fn new ( flags : HeaderTagFlag , requests : [ MbiTagTypeId ; N ] , size : Option < u32 > ) -> Self {
2627 InformationRequestHeaderTag {
2728 typ : HeaderTagType :: InformationRequest ,
2829 flags,
@@ -44,7 +45,7 @@ impl<const N: usize> InformationRequestHeaderTag<N> {
4445 /// Returns the requests as array. Only works if the number of requests
4546 /// is known at compile time. For safety and correctness during runtime,
4647 /// you should use `req_iter()`.
47- pub const fn requests ( & self ) -> [ MbiTagType ; N ] {
48+ pub const fn requests ( & self ) -> [ MbiTagTypeId ; N ] {
4849 // cheap to copy, otherwise difficult with lifetime
4950 self . requests
5051 }
@@ -70,7 +71,7 @@ impl<const N: usize> InformationRequestHeaderTag<N> {
7071 let base_ptr = self as * const InformationRequestHeaderTag < N > ;
7172 let base_ptr = base_ptr as * const u8 ;
7273 let base_ptr = unsafe { base_ptr. add ( base_struct_size) } ;
73- let base_ptr = base_ptr as * const MbiTagType ;
74+ let base_ptr = base_ptr as * const MbiTagTypeId ;
7475 InformationRequestHeaderTagIter :: new ( count, base_ptr)
7576 }
7677}
@@ -90,32 +91,32 @@ impl<const N: usize> Debug for InformationRequestHeaderTag<N> {
9091/// that are requested.
9192#[ derive( Copy , Clone ) ]
9293pub struct InformationRequestHeaderTagIter < ' a > {
93- base_ptr : * const MbiTagType ,
94+ base_ptr : * const MbiTagTypeId ,
9495 i : u32 ,
9596 count : u32 ,
9697 _marker : PhantomData < & ' a ( ) > ,
9798}
9899
99100impl < ' a > InformationRequestHeaderTagIter < ' a > {
100- fn new ( count : u32 , base_ptr : * const MbiTagType ) -> Self {
101- #[ allow( clippy:: default_constructed_unit_structs) ]
101+ const fn new ( count : u32 , base_ptr : * const MbiTagTypeId ) -> Self {
102102 Self {
103103 i : 0 ,
104104 count,
105105 base_ptr,
106- _marker : PhantomData :: default ( ) ,
106+ _marker : PhantomData ,
107107 }
108108 }
109109}
110110
111111impl < ' a > Iterator for InformationRequestHeaderTagIter < ' a > {
112- type Item = & ' a MbiTagType ;
112+ type Item = MbiTagType ;
113113
114114 fn next ( & mut self ) -> Option < Self :: Item > {
115115 if self . i < self . count {
116116 let ptr = unsafe { self . base_ptr . offset ( self . i as isize ) } ;
117117 self . i += 1 ;
118- Some ( unsafe { & * ptr } )
118+ let tag_type_id = unsafe { * ptr } ;
119+ Some ( TagType :: from ( tag_type_id) )
119120 } else {
120121 None
121122 }
@@ -126,7 +127,7 @@ impl<'a> Debug for InformationRequestHeaderTagIter<'a> {
126127 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
127128 let mut debug = f. debug_list ( ) ;
128129 ( * self ) . for_each ( |e| {
129- debug. entry ( e) ;
130+ debug. entry ( & e) ;
130131 } ) ;
131132 debug. finish ( )
132133 }
0 commit comments