multiboot2_header/
framebuffer.rs1use crate::{HeaderTagFlag, HeaderTagHeader, HeaderTagType};
2use multiboot2_common::{MaybeDynSized, Tag};
3
4#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9#[repr(C, align(8))]
10pub struct FramebufferHeaderTag {
11 header: HeaderTagHeader,
12 width: u32,
13 height: u32,
14 depth: u32,
15}
16
17impl FramebufferHeaderTag {
18 #[must_use]
20 pub const fn new(flags: HeaderTagFlag, width: u32, height: u32, depth: u32) -> Self {
21 let header =
22 HeaderTagHeader::new(HeaderTagType::Framebuffer, flags, Self::BASE_SIZE as u32);
23 Self {
24 header,
25 width,
26 height,
27 depth,
28 }
29 }
30
31 #[must_use]
33 pub const fn typ(&self) -> HeaderTagType {
34 self.header.typ()
35 }
36
37 #[must_use]
39 pub const fn flags(&self) -> HeaderTagFlag {
40 self.header.flags()
41 }
42
43 #[must_use]
45 pub const fn size(&self) -> u32 {
46 self.header.size()
47 }
48
49 #[must_use]
51 pub const fn width(&self) -> u32 {
52 self.width
53 }
54
55 #[must_use]
57 pub const fn height(&self) -> u32 {
58 self.height
59 }
60
61 #[must_use]
63 pub const fn depth(&self) -> u32 {
64 self.depth
65 }
66}
67
68impl MaybeDynSized for FramebufferHeaderTag {
69 type Header = HeaderTagHeader;
70
71 const BASE_SIZE: usize = size_of::<HeaderTagHeader>() + 3 * size_of::<u32>();
72}
73
74impl Tag for FramebufferHeaderTag {
75 type IDType = HeaderTagType;
76 const ID: HeaderTagType = HeaderTagType::Framebuffer;
77}