multiboot2_header/lib.rs
1//! Convenient and safe parsing of Multiboot2 Header structures and the
2//! contained header tags. Usable in `no_std` environments, such as a
3//! bootloader. The default `builder` feature also allows the construction of
4//! the corresponding structures.
5//!
6//! ## Design
7//!
8//! For every Multiboot2 header structure, there is an ABI-compatible rusty type.
9//! This enables a zero-copying parsing design while also enabling the creation
10//! of these structures via convenient constructors on the corresponding types.
11//!
12//! ## Features and `no_std` Compatibility
13//!
14//! This library is always `no_std`. The default `builder` feature enables
15//! `alloc`; using it requires an `#[global_allocator]`. Remove that feature if
16//! you do not need to construct headers.
17//!
18//! ## Example: Parsing a Header
19//!
20//! ```no_run
21//! use multiboot2_header::Header;
22//!
23//! let ptr = 0x1337_0000 as *const u8 /* use real ptr here */;
24//! let mb2_hdr = unsafe { Header::load(ptr.cast()) }.unwrap();
25//! for _tag in mb2_hdr.iter() {
26//! //
27//! }
28//! ```
29//!
30//! ## MSRV
31//!
32//! The MSRV is 1.85.1 stable.
33
34#![no_std]
35// --- BEGIN STYLE CHECKS ---
36#![deny(
37 clippy::all,
38 clippy::cargo,
39 clippy::nursery,
40 clippy::undocumented_unsafe_blocks,
41 clippy::must_use_candidate,
42 // clippy::restriction,
43 // clippy::pedantic
44)]
45// now allow a few rules which are denied by the above statement
46// --> They are either ridiculous, not necessary, or we can't fix them.
47#![allow(clippy::multiple_crate_versions)]
48#![deny(missing_docs)]
49#![deny(missing_debug_implementations)]
50#![deny(rustdoc::all)]
51// --- END STYLE CHECKS ---
52
53#[cfg(feature = "builder")]
54extern crate alloc;
55
56#[cfg_attr(test, macro_use)]
57#[cfg(test)]
58extern crate std;
59
60/// Iterator over the tags of a Multiboot2 header.
61pub type TagIter<'a> = multiboot2_common::TagIter<'a, HeaderTagHeader>;
62
63/// Generic dynamically sized representation of a Multiboot2 header tag.
64///
65/// This represents an entire header tag, including its variable payload, not
66/// the fixed-size [`HeaderTagHeader`] prefix.
67#[cfg(test)]
68pub type GenericHeaderTag = multiboot2_common::DynSizedStructure<HeaderTagHeader>;
69
70mod address;
71mod console;
72mod end;
73mod entry_address;
74mod entry_efi_32;
75mod entry_efi_64;
76mod framebuffer;
77mod header;
78mod information_request;
79mod module_align;
80mod relocatable;
81mod tags;
82mod uefi_bs;
83
84#[cfg(feature = "builder")]
85mod builder;
86
87pub use multiboot2_common::{DynSizedStructure, MaybeDynSized, Tag};
88
89pub use self::address::*;
90pub use self::console::*;
91pub use self::end::*;
92pub use self::entry_address::*;
93pub use self::entry_efi_32::*;
94pub use self::entry_efi_64::*;
95pub use self::framebuffer::*;
96pub use self::header::*;
97pub use self::information_request::*;
98pub use self::module_align::*;
99pub use self::relocatable::*;
100pub use self::tags::*;
101pub use self::uefi_bs::*;
102#[cfg(feature = "builder")]
103pub use builder::Builder;
104
105/// Re-export of [`multiboot2::TagType`] from `multiboot2`-crate.
106pub use multiboot2::{TagType as MbiTagType, TagTypeId as MbiTagTypeId};