use crate::{HeaderTagFlag, HeaderTagType};
use core::mem::size_of;
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
pub struct FramebufferHeaderTag {
typ: HeaderTagType,
flags: HeaderTagFlag,
size: u32,
width: u32,
height: u32,
depth: u32,
}
impl FramebufferHeaderTag {
pub const fn new(flags: HeaderTagFlag, width: u32, height: u32, depth: u32) -> Self {
FramebufferHeaderTag {
typ: HeaderTagType::Framebuffer,
flags,
size: size_of::<Self>() as u32,
width,
height,
depth,
}
}
pub const fn typ(&self) -> HeaderTagType {
self.typ
}
pub const fn flags(&self) -> HeaderTagFlag {
self.flags
}
pub const fn size(&self) -> u32 {
self.size
}
pub const fn width(&self) -> u32 {
self.width
}
pub const fn height(&self) -> u32 {
self.height
}
pub const fn depth(&self) -> u32 {
self.depth
}
}
#[cfg(test)]
mod tests {
use crate::FramebufferHeaderTag;
#[test]
fn test_assert_size() {
assert_eq!(
core::mem::size_of::<FramebufferHeaderTag>(),
2 + 2 + 4 + 4 + 4 + 4
);
}
}