lib.rs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. An optional 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. //! # Example: Parsing a Header
  13. //!
  14. //! ```no_run
  15. //! use multiboot2_header::Multiboot2Header;
  16. //!
  17. //! let ptr = 0x1337_0000 as *const u8 /* use real ptr here */;
  18. //! let mb2_hdr = unsafe { Multiboot2Header::load(ptr.cast()) }.unwrap();
  19. //! for _tag in mb2_hdr.iter() {
  20. //! //
  21. //! }
  22. //! ```
  23. //!
  24. //! ## MSRV
  25. //!
  26. //! The MSRV is 1.70.0 stable.
  27. #![no_std]
  28. #![cfg_attr(feature = "unstable", feature(error_in_core))]
  29. // --- BEGIN STYLE CHECKS ---
  30. #![deny(
  31. clippy::all,
  32. clippy::cargo,
  33. clippy::nursery,
  34. clippy::must_use_candidate,
  35. // clippy::restriction,
  36. // clippy::pedantic
  37. )]
  38. // now allow a few rules which are denied by the above statement
  39. // --> They are either ridiculous, not necessary, or we can't fix them.
  40. #![allow(clippy::multiple_crate_versions)]
  41. #![deny(missing_docs)]
  42. #![deny(missing_debug_implementations)]
  43. #![deny(rustdoc::all)]
  44. // --- END STYLE CHECKS ---
  45. #[cfg(feature = "builder")]
  46. extern crate alloc;
  47. #[cfg_attr(test, macro_use)]
  48. #[cfg(test)]
  49. extern crate std;
  50. /// Iterator over the tags of a Multiboot2 boot information.
  51. pub type TagIter<'a> = multiboot2_common::TagIter<'a, HeaderTagHeader>;
  52. /// A generic version of all boot information tags.
  53. #[cfg(test)]
  54. pub type GenericHeaderTag = multiboot2_common::DynSizedStructure<HeaderTagHeader>;
  55. mod address;
  56. mod console;
  57. mod end;
  58. mod entry_address;
  59. mod entry_efi_32;
  60. mod entry_efi_64;
  61. mod framebuffer;
  62. mod header;
  63. mod information_request;
  64. mod module_align;
  65. mod relocatable;
  66. mod tags;
  67. mod uefi_bs;
  68. #[cfg(feature = "builder")]
  69. mod builder;
  70. pub use multiboot2_common::{DynSizedStructure, MaybeDynSized, Tag};
  71. pub use self::address::*;
  72. pub use self::console::*;
  73. pub use self::end::*;
  74. pub use self::entry_address::*;
  75. pub use self::entry_efi_32::*;
  76. pub use self::entry_efi_64::*;
  77. pub use self::framebuffer::*;
  78. pub use self::header::*;
  79. pub use self::information_request::*;
  80. pub use self::module_align::*;
  81. pub use self::relocatable::*;
  82. pub use self::tags::*;
  83. pub use self::uefi_bs::*;
  84. #[cfg(feature = "builder")]
  85. pub use builder::Builder;
  86. /// Re-export of [`multiboot2::TagType`] from `multiboot2`-crate.
  87. pub use multiboot2::{TagType as MbiTagType, TagTypeId as MbiTagTypeId};