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