Skip to content

tree-wide: rename builder structs (remove Multiboot2 prefix) #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions multiboot2-header/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- added the optional `unstable` feature (requires nightly)
- implement `core::error::Error` for `LoadError`
- depends on `multiboot2@v0.16.0`
- **BREAKING** renamed `Multiboot2HeaderBuilder` to `HeaderBuilder`

## 0.2.0 (2022-05-03)
- **BREAKING** renamed `EntryHeaderTag` to `EntryAddressHeaderTag`
Expand Down
4 changes: 2 additions & 2 deletions multiboot2-header/examples/minimal.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use multiboot2_header::builder::{InformationRequestHeaderTagBuilder, Multiboot2HeaderBuilder};
use multiboot2_header::builder::{HeaderBuilder, InformationRequestHeaderTagBuilder};
use multiboot2_header::{
HeaderTagFlag, HeaderTagISA, MbiTagType, Multiboot2Header, RelocatableHeaderTag,
RelocatableHeaderTagPreference,
Expand All @@ -8,7 +8,7 @@ use multiboot2_header::{
fn main() {
// We create a Multiboot2 header during runtime here. A practical example is that your
// program gets the header from a file and parses it afterwards.
let mb2_hdr_bytes = Multiboot2HeaderBuilder::new(HeaderTagISA::I386)
let mb2_hdr_bytes = HeaderBuilder::new(HeaderTagISA::I386)
.relocatable_tag(RelocatableHeaderTag::new(
HeaderTagFlag::Required,
0x1337,
Expand Down
18 changes: 9 additions & 9 deletions multiboot2-header/src/builder/header.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Exports item [`Multiboot2HeaderBuilder`].
//! Exports item [`HeaderBuilder`].

use crate::builder::information_request::InformationRequestHeaderTagBuilder;
use crate::builder::traits::StructAsBytes;
Expand All @@ -15,7 +15,7 @@ use core::mem::size_of;
/// The tags will appear in the order of their corresponding enumeration,
/// except for the END tag.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Multiboot2HeaderBuilder {
pub struct HeaderBuilder {
arch: HeaderTagISA,
// first
information_request_tag: Option<InformationRequestHeaderTagBuilder>,
Expand All @@ -39,7 +39,7 @@ pub struct Multiboot2HeaderBuilder {
relocatable_tag: Option<RelocatableHeaderTag>,
}

impl Multiboot2HeaderBuilder {
impl HeaderBuilder {
pub const fn new(arch: HeaderTagISA) -> Self {
Self {
arch,
Expand Down Expand Up @@ -228,7 +228,7 @@ impl Multiboot2HeaderBuilder {

#[cfg(test)]
mod tests {
use crate::builder::header::Multiboot2HeaderBuilder;
use crate::builder::header::HeaderBuilder;
use crate::builder::information_request::InformationRequestHeaderTagBuilder;
use crate::{
HeaderTagFlag, HeaderTagISA, MbiTagType, Multiboot2Header, RelocatableHeaderTag,
Expand All @@ -237,15 +237,15 @@ mod tests {

#[test]
fn test_size_or_up_aligned() {
assert_eq!(0, Multiboot2HeaderBuilder::size_or_up_aligned(0));
assert_eq!(8, Multiboot2HeaderBuilder::size_or_up_aligned(1));
assert_eq!(8, Multiboot2HeaderBuilder::size_or_up_aligned(8));
assert_eq!(16, Multiboot2HeaderBuilder::size_or_up_aligned(9));
assert_eq!(0, HeaderBuilder::size_or_up_aligned(0));
assert_eq!(8, HeaderBuilder::size_or_up_aligned(1));
assert_eq!(8, HeaderBuilder::size_or_up_aligned(8));
assert_eq!(16, HeaderBuilder::size_or_up_aligned(9));
}

#[test]
fn test_builder() {
let builder = Multiboot2HeaderBuilder::new(HeaderTagISA::I386);
let builder = HeaderBuilder::new(HeaderTagISA::I386);
// Multiboot2 basic header + end tag
let mut expected_len = 16 + 8;
assert_eq!(builder.expected_len(), expected_len);
Expand Down
2 changes: 1 addition & 1 deletion multiboot2-header/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ mod header;
mod information_request;
pub(self) mod traits;

pub use header::Multiboot2HeaderBuilder;
pub use header::HeaderBuilder;
pub use information_request::InformationRequestHeaderTagBuilder;
2 changes: 1 addition & 1 deletion multiboot2-header/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub const MULTIBOOT2_HEADER_MAGIC: u32 = 0xe85250d6;
/// by all tags (see [`crate::tags::HeaderTagType`]).
/// Use this if you get a pointer to the header and just want
/// to parse it. If you want to construct the type by yourself,
/// please look at [`crate::builder::Multiboot2HeaderBuilder`].
/// please look at [`crate::builder::HeaderBuilder`].
#[repr(transparent)]
pub struct Multiboot2Header<'a> {
inner: &'a Multiboot2BasicHeader,
Expand Down
4 changes: 2 additions & 2 deletions multiboot2-header/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
//!
//! # Example
//! ```rust
//! use multiboot2_header::builder::{InformationRequestHeaderTagBuilder, Multiboot2HeaderBuilder};
//! use multiboot2_header::builder::{InformationRequestHeaderTagBuilder, HeaderBuilder};
//! use multiboot2_header::{HeaderTagFlag, HeaderTagISA, MbiTagType, RelocatableHeaderTag, RelocatableHeaderTagPreference, Multiboot2Header};
//!
//! // Small example that creates a Multiboot2 header and parses it afterwards.
//!
//! // We create a Multiboot2 header during runtime here. A practical example is that your
//! // program gets the header from a file and parses it afterwards.
//! let mb2_hdr_bytes = Multiboot2HeaderBuilder::new(HeaderTagISA::I386)
//! let mb2_hdr_bytes = HeaderBuilder::new(HeaderTagISA::I386)
//! .relocatable_tag(RelocatableHeaderTag::new(
//! HeaderTagFlag::Required,
//! 0x1337,
Expand Down
4 changes: 2 additions & 2 deletions multiboot2/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
tags that use DSTs as types. See the example provided in the doc of the
`get_tag` method.
- renamed `MULTIBOOT2_BOOTLOADER_MAGIC` to `MAGIC`
- added a `builder` feature and a `builder` module with a `Multiboot2InformationBuilder`
struct
- added a `builder` feature and a `builder` module with a
`builder::InformationBuilder` struct
- `EFIMemoryDesc` was removed and is now an alias of
`uefi_raw::table::boot::MemoryDescriptor`
- `EFIMemoryAreaType` was removed and is now an alias of
Expand Down
18 changes: 9 additions & 9 deletions multiboot2/src/builder/information.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Exports item [`Multiboot2InformationBuilder`].
//! Exports item [`InformationBuilder`].
use crate::builder::traits::StructAsBytes;
use crate::{
BasicMemoryInfoTag, BootInformationInner, BootLoaderNameTag, CommandLineTag,
Expand All @@ -16,7 +16,7 @@ use core::mem::size_of;
/// except for the END tag.
#[derive(Debug)]
// #[derive(Debug, PartialEq, Eq)] // wait for uefi-raw 0.3.0
pub struct Multiboot2InformationBuilder {
pub struct InformationBuilder {
basic_memory_info_tag: Option<BasicMemoryInfoTag>,
boot_loader_name_tag: Option<Box<BootLoaderNameTag>>,
command_line_tag: Option<Box<CommandLineTag>>,
Expand All @@ -36,7 +36,7 @@ pub struct Multiboot2InformationBuilder {
smbios_tags: Vec<Box<SmbiosTag>>,
}

impl Multiboot2InformationBuilder {
impl InformationBuilder {
pub const fn new() -> Self {
Self {
basic_memory_info_tag: None,
Expand Down Expand Up @@ -289,20 +289,20 @@ impl Multiboot2InformationBuilder {

#[cfg(test)]
mod tests {
use crate::builder::information::Multiboot2InformationBuilder;
use crate::builder::information::InformationBuilder;
use crate::{load, BasicMemoryInfoTag, CommandLineTag, ModuleTag};

#[test]
fn test_size_or_up_aligned() {
assert_eq!(0, Multiboot2InformationBuilder::size_or_up_aligned(0));
assert_eq!(8, Multiboot2InformationBuilder::size_or_up_aligned(1));
assert_eq!(8, Multiboot2InformationBuilder::size_or_up_aligned(8));
assert_eq!(16, Multiboot2InformationBuilder::size_or_up_aligned(9));
assert_eq!(0, InformationBuilder::size_or_up_aligned(0));
assert_eq!(8, InformationBuilder::size_or_up_aligned(1));
assert_eq!(8, InformationBuilder::size_or_up_aligned(8));
assert_eq!(16, InformationBuilder::size_or_up_aligned(9));
}

#[test]
fn test_builder() {
let mut builder = Multiboot2InformationBuilder::new();
let mut builder = InformationBuilder::new();
// Multiboot2 basic information + end tag
let mut expected_len = 8 + 8;
assert_eq!(builder.expected_len(), expected_len);
Expand Down
2 changes: 1 addition & 1 deletion multiboot2/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
mod information;
pub(crate) mod traits;

pub use information::Multiboot2InformationBuilder;
pub use information::InformationBuilder;

use alloc::alloc::alloc;
use alloc::boxed::Box;
Expand Down