@@ -46,7 +46,7 @@ pub struct BootInformationHeader {
4646
4747#[ cfg( feature = "builder" ) ]
4848impl BootInformationHeader {
49- pub ( crate ) fn new ( total_size : u32 ) -> Self {
49+ pub ( crate ) const fn new ( total_size : u32 ) -> Self {
5050 Self {
5151 total_size,
5252 _reserved : 0 ,
@@ -140,12 +140,14 @@ impl<'a> BootInformation<'a> {
140140 }
141141
142142 /// Get the start address of the boot info.
143+ #[ must_use]
143144 pub fn start_address ( & self ) -> usize {
144145 self . as_ptr ( ) as usize
145146 }
146147
147148 /// Get the start address of the boot info as pointer.
148- pub fn as_ptr ( & self ) -> * const ( ) {
149+ #[ must_use]
150+ pub const fn as_ptr ( & self ) -> * const ( ) {
149151 core:: ptr:: addr_of!( * self . 0 ) . cast ( )
150152 }
151153
@@ -159,12 +161,14 @@ impl<'a> BootInformation<'a> {
159161 /// # let boot_info = unsafe { BootInformation::load(ptr).unwrap() };
160162 /// let end_addr = boot_info.start_address() + boot_info.total_size();
161163 /// ```
164+ #[ must_use]
162165 pub fn end_address ( & self ) -> usize {
163166 self . start_address ( ) + self . total_size ( )
164167 }
165168
166169 /// Get the total size of the boot info struct.
167- pub fn total_size ( & self ) -> usize {
170+ #[ must_use]
171+ pub const fn total_size ( & self ) -> usize {
168172 self . 0 . header . total_size as usize
169173 }
170174
@@ -177,11 +181,13 @@ impl<'a> BootInformation<'a> {
177181 }*/
178182
179183 /// Search for the basic memory info tag.
184+ #[ must_use]
180185 pub fn basic_memory_info_tag ( & self ) -> Option < & BasicMemoryInfoTag > {
181186 self . get_tag :: < BasicMemoryInfoTag > ( )
182187 }
183188
184189 /// Search for the BootLoader name tag.
190+ #[ must_use]
185191 pub fn boot_loader_name_tag ( & self ) -> Option < & BootLoaderNameTag > {
186192 self . get_tag :: < BootLoaderNameTag > ( )
187193 }
@@ -192,11 +198,13 @@ impl<'a> BootInformation<'a> {
192198 }*/
193199
194200 /// Search for the Command line tag.
201+ #[ must_use]
195202 pub fn command_line_tag ( & self ) -> Option < & CommandLineTag > {
196203 self . get_tag :: < CommandLineTag > ( )
197204 }
198205
199206 /// Search for the EFI boot services not exited tag.
207+ #[ must_use]
200208 pub fn efi_bs_not_exited_tag ( & self ) -> Option < & EFIBootServicesNotExitedTag > {
201209 self . get_tag :: < EFIBootServicesNotExitedTag > ( )
202210 }
@@ -205,34 +213,37 @@ impl<'a> BootInformation<'a> {
205213 /// Otherwise, if the [`TagType::EfiBs`] tag is present, this returns `None`
206214 /// as it is strictly recommended to get the memory map from the `uefi`
207215 /// services.
216+ #[ must_use]
208217 pub fn efi_memory_map_tag ( & self ) -> Option < & EFIMemoryMapTag > {
209218 // If the EFIBootServicesNotExited is present, then we should not use
210219 // the memory map, as it could still be in use.
211- match self . get_tag :: < EFIBootServicesNotExitedTag > ( ) {
212- Some ( _tag) => {
213- log:: debug!( "The EFI memory map is present but the UEFI Boot Services Not Existed Tag is present. Returning None." ) ;
214- None
215- }
216- None => self . get_tag :: < EFIMemoryMapTag > ( ) ,
217- }
220+ self . get_tag :: < EFIBootServicesNotExitedTag > ( ) . map_or_else (
221+ || self . get_tag :: < EFIMemoryMapTag > ( ) , |_tag| {
222+ log:: debug!( "The EFI memory map is present but the UEFI Boot Services Not Existed Tag is present. Returning None." ) ;
223+ None
224+ } )
218225 }
219226
220227 /// Search for the EFI 32-bit SDT tag.
228+ #[ must_use]
221229 pub fn efi_sdt32_tag ( & self ) -> Option < & EFISdt32Tag > {
222230 self . get_tag :: < EFISdt32Tag > ( )
223231 }
224232
225233 /// Search for the EFI 64-bit SDT tag.
234+ #[ must_use]
226235 pub fn efi_sdt64_tag ( & self ) -> Option < & EFISdt64Tag > {
227236 self . get_tag :: < EFISdt64Tag > ( )
228237 }
229238
230239 /// Search for the EFI 32-bit image handle pointer tag.
240+ #[ must_use]
231241 pub fn efi_ih32_tag ( & self ) -> Option < & EFIImageHandle32Tag > {
232242 self . get_tag :: < EFIImageHandle32Tag > ( )
233243 }
234244
235245 /// Search for the EFI 64-bit image handle pointer tag.
246+ #[ must_use]
236247 pub fn efi_ih64_tag ( & self ) -> Option < & EFIImageHandle64Tag > {
237248 self . get_tag :: < EFIImageHandle64Tag > ( )
238249 }
@@ -254,6 +265,7 @@ impl<'a> BootInformation<'a> {
254265 /// }
255266 /// }
256267 /// ```
268+ #[ must_use]
257269 pub fn elf_sections ( & self ) -> Option < ElfSectionIter > {
258270 let tag = self . get_tag :: < ElfSectionsTag > ( ) ;
259271 tag. map ( |t| {
@@ -264,6 +276,7 @@ impl<'a> BootInformation<'a> {
264276
265277 /// Search for the VBE framebuffer tag. The result is `Some(Err(e))`, if the
266278 /// framebuffer type is unknown, while the framebuffer tag is present.
279+ #[ must_use]
267280 pub fn framebuffer_tag ( & self ) -> Option < Result < & FramebufferTag , UnknownFramebufferType > > {
268281 self . get_tag :: < FramebufferTag > ( )
269282 . map ( |tag| match tag. buffer_type ( ) {
@@ -273,16 +286,19 @@ impl<'a> BootInformation<'a> {
273286 }
274287
275288 /// Search for the Image Load Base Physical Address tag.
289+ #[ must_use]
276290 pub fn load_base_addr_tag ( & self ) -> Option < & ImageLoadPhysAddrTag > {
277291 self . get_tag :: < ImageLoadPhysAddrTag > ( )
278292 }
279293
280294 /// Search for the Memory map tag.
295+ #[ must_use]
281296 pub fn memory_map_tag ( & self ) -> Option < & MemoryMapTag > {
282297 self . get_tag :: < MemoryMapTag > ( )
283298 }
284299
285300 /// Get an iterator of all module tags.
301+ #[ must_use]
286302 pub fn module_tags ( & self ) -> ModuleIter {
287303 module:: module_iter ( self . tags ( ) )
288304 }
@@ -293,21 +309,25 @@ impl<'a> BootInformation<'a> {
293309 }*/
294310
295311 /// Search for the (ACPI 1.0) RSDP tag.
312+ #[ must_use]
296313 pub fn rsdp_v1_tag ( & self ) -> Option < & RsdpV1Tag > {
297314 self . get_tag :: < RsdpV1Tag > ( )
298315 }
299316
300317 /// Search for the (ACPI 2.0 or later) RSDP tag.
318+ #[ must_use]
301319 pub fn rsdp_v2_tag ( & self ) -> Option < & RsdpV2Tag > {
302320 self . get_tag :: < RsdpV2Tag > ( )
303321 }
304322
305323 /// Search for the SMBIOS tag.
324+ #[ must_use]
306325 pub fn smbios_tag ( & self ) -> Option < & SmbiosTag > {
307326 self . get_tag :: < SmbiosTag > ( )
308327 }
309328
310329 /// Search for the VBE information tag.
330+ #[ must_use]
311331 pub fn vbe_info_tag ( & self ) -> Option < & VBEInfoTag > {
312332 self . get_tag :: < VBEInfoTag > ( )
313333 }
@@ -367,6 +387,7 @@ impl<'a> BootInformation<'a> {
367387 /// .unwrap();
368388 /// assert_eq!(tag.name(), Ok("name"));
369389 /// ```
390+ #[ must_use]
370391 pub fn get_tag < TagT : TagTrait + ?Sized + ' a > ( & ' a self ) -> Option < & ' a TagT > {
371392 self . tags ( )
372393 . find ( |tag| tag. typ == TagT :: ID )
0 commit comments