Skip to content

Commit 02b53ce

Browse files
committed
Make InformationBuilder adhere the API guidelines.
The API guidelines state that methods of builders should return `self` to allow chaining. Add missing documentation strings to builder functions.
1 parent 05cd98d commit 02b53ce

File tree

1 file changed

+76
-22
lines changed

1 file changed

+76
-22
lines changed

multiboot2/src/builder/information.rs

Lines changed: 76 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -287,72 +287,126 @@ impl InformationBuilder {
287287
Self::build_add_bytes(bytes, &EndTag::default().struct_as_bytes(), true);
288288
}
289289

290-
pub fn basic_memory_info_tag(&mut self, basic_memory_info_tag: BasicMemoryInfoTag) {
291-
self.basic_memory_info_tag = Some(basic_memory_info_tag)
290+
/// Adds a 'basic memory information' tag (represented by [`BasicMemoryInfoTag`]) to the builder to later build the
291+
/// boot information from.
292+
pub fn basic_memory_info_tag(mut self, basic_memory_info_tag: BasicMemoryInfoTag) -> Self {
293+
self.basic_memory_info_tag = Some(basic_memory_info_tag);
294+
self
292295
}
293296

294-
pub fn bootloader_name_tag(&mut self, boot_loader_name_tag: BoxedDst<BootLoaderNameTag>) {
297+
/// Adds a 'bootloader name' tag (represented by [`BootLoaderNameTag`]) to the builder to later build the
298+
/// boot information from.
299+
pub fn bootloader_name_tag(
300+
mut self,
301+
boot_loader_name_tag: BoxedDst<BootLoaderNameTag>,
302+
) -> Self {
295303
self.boot_loader_name_tag = Some(boot_loader_name_tag);
304+
self
296305
}
297306

298-
pub fn command_line_tag(&mut self, command_line_tag: BoxedDst<CommandLineTag>) {
307+
/// Adds a 'command line' tag (represented by [`CommandLineTag`]) to the builder to later build the
308+
/// boot information from.
309+
pub fn command_line_tag(mut self, command_line_tag: BoxedDst<CommandLineTag>) -> Self {
299310
self.command_line_tag = Some(command_line_tag);
311+
self
300312
}
301313

302-
pub fn efisdt32_tag(&mut self, efisdt32: EFISdt32Tag) {
314+
/// Adds a 'EFI 32-bit system table pointer' tag (represented by [`EFISdt32Tag`]) to the builder to later build the
315+
/// boot information from.
316+
pub fn efisdt32_tag(mut self, efisdt32: EFISdt32Tag) -> Self {
303317
self.efisdt32_tag = Some(efisdt32);
318+
self
304319
}
305320

306-
pub fn efisdt64_tag(&mut self, efisdt64: EFISdt64Tag) {
321+
/// Adds a 'EFI 64-bit system table pointer' tag (represented by [`EFISdt64Tag`]) to the builder to later build the
322+
/// boot information from.
323+
pub fn efisdt64_tag(mut self, efisdt64: EFISdt64Tag) -> Self {
307324
self.efisdt64_tag = Some(efisdt64);
325+
self
308326
}
309327

310-
pub fn efi_boot_services_not_exited_tag(&mut self) {
328+
/// Adds a 'EFI boot services not terminated' tag (represented by [`EFIBootServicesNotExitedTag`]) to the builder
329+
/// to later build the boot information from.
330+
pub fn efi_boot_services_not_exited_tag(mut self) -> Self {
311331
self.efi_boot_services_not_exited_tag = Some(EFIBootServicesNotExitedTag::new());
332+
self
312333
}
313334

314-
pub fn efi_image_handle32(&mut self, efi_image_handle32: EFIImageHandle32Tag) {
335+
/// Adds a 'EFI 32-bit image handle pointer' tag (represented by [`EFIImageHandle32Tag`]) to the builder
336+
/// to later build the boot information from.
337+
pub fn efi_image_handle32(mut self, efi_image_handle32: EFIImageHandle32Tag) -> Self {
315338
self.efi_image_handle32 = Some(efi_image_handle32);
339+
self
316340
}
317341

318-
pub fn efi_image_handle64(&mut self, efi_image_handle64: EFIImageHandle64Tag) {
342+
/// Adds a 'EFI 64-bit image handle pointer' tag (represented by [`EFIImageHandle64Tag`]) to the builder
343+
/// to later build the boot information from.
344+
pub fn efi_image_handle64(mut self, efi_image_handle64: EFIImageHandle64Tag) -> Self {
319345
self.efi_image_handle64 = Some(efi_image_handle64);
346+
self
320347
}
321348

322-
pub fn efi_memory_map_tag(&mut self, efi_memory_map_tag: BoxedDst<EFIMemoryMapTag>) {
349+
/// Adds a 'EFI Memory map' tag (represented by [`EFIMemoryMapTag`]) to the builder
350+
/// to later build the boot information from.
351+
pub fn efi_memory_map_tag(mut self, efi_memory_map_tag: BoxedDst<EFIMemoryMapTag>) -> Self {
323352
self.efi_memory_map_tag = Some(efi_memory_map_tag);
353+
self
324354
}
325355

326-
pub fn elf_sections_tag(&mut self, elf_sections_tag: BoxedDst<ElfSectionsTag>) {
356+
/// Adds a 'ELF-Symbols' tag (represented by [`ElfSectionsTag`]) to the builder
357+
/// to later build the boot information from.
358+
pub fn elf_sections_tag(mut self, elf_sections_tag: BoxedDst<ElfSectionsTag>) -> Self {
327359
self.elf_sections_tag = Some(elf_sections_tag);
360+
self
328361
}
329362

330-
pub fn framebuffer_tag(&mut self, framebuffer_tag: BoxedDst<FramebufferTag>) {
363+
/// Adds a 'Framebuffer info' tag (represented by [`FramebufferTag`]) to the builder
364+
/// to later build the boot information from.
365+
pub fn framebuffer_tag(mut self, framebuffer_tag: BoxedDst<FramebufferTag>) -> Self {
331366
self.framebuffer_tag = Some(framebuffer_tag);
367+
self
332368
}
333369

334-
pub fn image_load_addr(&mut self, image_load_addr: ImageLoadPhysAddrTag) {
370+
/// Adds a 'Image load base physical address' tag (represented by [`ImageLoadPhysAddrTag`]) to the builder
371+
/// to later build the boot information from.
372+
pub fn image_load_addr(mut self, image_load_addr: ImageLoadPhysAddrTag) -> Self {
335373
self.image_load_addr = Some(image_load_addr);
374+
self
336375
}
337376

338-
pub fn memory_map_tag(&mut self, memory_map_tag: BoxedDst<MemoryMapTag>) {
377+
/// Adds a (*none EFI*) 'memory map' tag (represented by [`MemoryMapTag`]) to the builder
378+
/// to later build the boot information from.
379+
pub fn memory_map_tag(mut self, memory_map_tag: BoxedDst<MemoryMapTag>) -> Self {
339380
self.memory_map_tag = Some(memory_map_tag);
381+
self
340382
}
341383

342-
pub fn add_module_tag(&mut self, module_tag: BoxedDst<ModuleTag>) {
384+
/// Adds a 'Modules' tag (represented by [`ModuleTag`]) to the builder
385+
/// to later build the boot information from. This tag can occur multiple times in boot information.
386+
pub fn add_module_tag(mut self, module_tag: BoxedDst<ModuleTag>) -> Self {
343387
self.module_tags.push(module_tag);
388+
self
344389
}
345390

346-
pub fn rsdp_v1_tag(&mut self, rsdp_v1_tag: RsdpV1Tag) {
391+
/// Adds a 'ACPI old RSDP' tag (represented by [`RsdpV1Tag`]) to the builder
392+
/// to later build the boot information from.
393+
pub fn rsdp_v1_tag(mut self, rsdp_v1_tag: RsdpV1Tag) -> Self {
347394
self.rsdp_v1_tag = Some(rsdp_v1_tag);
395+
self
348396
}
349397

350-
pub fn rsdp_v2_tag(&mut self, rsdp_v2_tag: RsdpV2Tag) {
398+
/// Adds a 'ACPI new RSDP' tag (represented by [`RsdpV2Tag`]) to the builder
399+
/// to later build the boot information from.
400+
pub fn rsdp_v2_tag(mut self, rsdp_v2_tag: RsdpV2Tag) -> Self {
351401
self.rsdp_v2_tag = Some(rsdp_v2_tag);
402+
self
352403
}
353404

354-
pub fn add_smbios_tag(&mut self, smbios_tag: BoxedDst<SmbiosTag>) {
405+
/// Adds a 'SMBIOS tables' tag (represented by [`SmbiosTag`]) to the builder
406+
/// to later build the boot information from.
407+
pub fn add_smbios_tag(mut self, smbios_tag: BoxedDst<SmbiosTag>) -> Self {
355408
self.smbios_tags.push(smbios_tag);
409+
self
356410
}
357411
}
358412

@@ -369,18 +423,18 @@ mod tests {
369423
assert_eq!(builder.expected_len(), expected_len);
370424

371425
// the most simple tag
372-
builder.basic_memory_info_tag(BasicMemoryInfoTag::new(640, 7 * 1024));
426+
builder = builder.basic_memory_info_tag(BasicMemoryInfoTag::new(640, 7 * 1024));
373427
expected_len += 16;
374428
assert_eq!(builder.expected_len(), expected_len);
375429
// a tag that has a dynamic size
376-
builder.command_line_tag(CommandLineTag::new("test"));
430+
builder = builder.command_line_tag(CommandLineTag::new("test"));
377431
expected_len += 8 + 5 + 3; // padding
378432
assert_eq!(builder.expected_len(), expected_len);
379433
// many modules
380-
builder.add_module_tag(ModuleTag::new(0, 1234, "module1"));
434+
builder = builder.add_module_tag(ModuleTag::new(0, 1234, "module1"));
381435
expected_len += 16 + 8;
382436
assert_eq!(builder.expected_len(), expected_len);
383-
builder.add_module_tag(ModuleTag::new(5678, 6789, "module2"));
437+
builder = builder.add_module_tag(ModuleTag::new(5678, 6789, "module2"));
384438
expected_len += 16 + 8;
385439
assert_eq!(builder.expected_len(), expected_len);
386440

0 commit comments

Comments
 (0)