Struct multiboot2_header::builder::HeaderBuilder
source · pub struct HeaderBuilder { /* private fields */ }Expand description
Builder to construct a valid Multiboot2 header dynamically at runtime. The tags will appear in the order of their corresponding enumeration, except for the END tag.
Implementations§
source§impl HeaderBuilder
impl HeaderBuilder
sourcepub const fn new(arch: HeaderTagISA) -> Self
pub const fn new(arch: HeaderTagISA) -> Self
Examples found in repository?
examples/minimal.rs (line 11)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
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 = HeaderBuilder::new(HeaderTagISA::I386)
.relocatable_tag(RelocatableHeaderTag::new(
HeaderTagFlag::Required,
0x1337,
0xdeadbeef,
4096,
RelocatableHeaderTagPreference::None,
))
.information_request_tag(
InformationRequestHeaderTagBuilder::new(HeaderTagFlag::Required)
.add_irs(&[MbiTagType::Cmdline, MbiTagType::BootLoaderName]),
)
.build();
// Cast bytes in vector to Multiboot2 information structure
let mb2_hdr = unsafe { Multiboot2Header::load(mb2_hdr_bytes.as_ptr().cast()) };
println!("{:#?}", mb2_hdr);
}sourcepub fn expected_len(&self) -> usize
pub fn expected_len(&self) -> usize
Returns the expected length of the Multiboot2 header, when the
Self::build-method gets called.
sourcepub fn build(self) -> HeaderBytes
pub fn build(self) -> HeaderBytes
Constructs the bytes for a valid Multiboot2 header with the given properties.
Examples found in repository?
examples/minimal.rs (line 23)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
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 = HeaderBuilder::new(HeaderTagISA::I386)
.relocatable_tag(RelocatableHeaderTag::new(
HeaderTagFlag::Required,
0x1337,
0xdeadbeef,
4096,
RelocatableHeaderTagPreference::None,
))
.information_request_tag(
InformationRequestHeaderTagBuilder::new(HeaderTagFlag::Required)
.add_irs(&[MbiTagType::Cmdline, MbiTagType::BootLoaderName]),
)
.build();
// Cast bytes in vector to Multiboot2 information structure
let mb2_hdr = unsafe { Multiboot2Header::load(mb2_hdr_bytes.as_ptr().cast()) };
println!("{:#?}", mb2_hdr);
}sourcepub fn information_request_tag(
self,
information_request_tag: InformationRequestHeaderTagBuilder
) -> Self
pub fn information_request_tag( self, information_request_tag: InformationRequestHeaderTagBuilder ) -> Self
Examples found in repository?
examples/minimal.rs (lines 19-22)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
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 = HeaderBuilder::new(HeaderTagISA::I386)
.relocatable_tag(RelocatableHeaderTag::new(
HeaderTagFlag::Required,
0x1337,
0xdeadbeef,
4096,
RelocatableHeaderTagPreference::None,
))
.information_request_tag(
InformationRequestHeaderTagBuilder::new(HeaderTagFlag::Required)
.add_irs(&[MbiTagType::Cmdline, MbiTagType::BootLoaderName]),
)
.build();
// Cast bytes in vector to Multiboot2 information structure
let mb2_hdr = unsafe { Multiboot2Header::load(mb2_hdr_bytes.as_ptr().cast()) };
println!("{:#?}", mb2_hdr);
}pub const fn address_tag(self, address_tag: AddressHeaderTag) -> Self
pub const fn entry_tag(self, entry_tag: EntryAddressHeaderTag) -> Self
pub const fn console_tag(self, console_tag: ConsoleHeaderTag) -> Self
pub const fn framebuffer_tag( self, framebuffer_tag: FramebufferHeaderTag ) -> Self
pub const fn module_align_tag( self, module_align_tag: ModuleAlignHeaderTag ) -> Self
pub const fn efi_bs_tag(self, efi_bs_tag: EfiBootServiceHeaderTag) -> Self
pub const fn efi_32_tag(self, efi_32_tag: EntryEfi32HeaderTag) -> Self
pub const fn efi_64_tag(self, efi_64_tag: EntryEfi64HeaderTag) -> Self
sourcepub const fn relocatable_tag(
self,
relocatable_tag: RelocatableHeaderTag
) -> Self
pub const fn relocatable_tag( self, relocatable_tag: RelocatableHeaderTag ) -> Self
Examples found in repository?
examples/minimal.rs (lines 12-18)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
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 = HeaderBuilder::new(HeaderTagISA::I386)
.relocatable_tag(RelocatableHeaderTag::new(
HeaderTagFlag::Required,
0x1337,
0xdeadbeef,
4096,
RelocatableHeaderTagPreference::None,
))
.information_request_tag(
InformationRequestHeaderTagBuilder::new(HeaderTagFlag::Required)
.add_irs(&[MbiTagType::Cmdline, MbiTagType::BootLoaderName]),
)
.build();
// Cast bytes in vector to Multiboot2 information structure
let mb2_hdr = unsafe { Multiboot2Header::load(mb2_hdr_bytes.as_ptr().cast()) };
println!("{:#?}", mb2_hdr);
}Trait Implementations§
source§impl Clone for HeaderBuilder
impl Clone for HeaderBuilder
source§fn clone(&self) -> HeaderBuilder
fn clone(&self) -> HeaderBuilder
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for HeaderBuilder
impl Debug for HeaderBuilder
source§impl PartialEq for HeaderBuilder
impl PartialEq for HeaderBuilder
source§fn eq(&self, other: &HeaderBuilder) -> bool
fn eq(&self, other: &HeaderBuilder) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Eq for HeaderBuilder
impl StructuralPartialEq for HeaderBuilder
Auto Trait Implementations§
impl Freeze for HeaderBuilder
impl RefUnwindSafe for HeaderBuilder
impl Send for HeaderBuilder
impl Sync for HeaderBuilder
impl Unpin for HeaderBuilder
impl UnwindSafe for HeaderBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more