use crate::{TagType, TagTypeRaw};
use core::fmt::Debug;
use multiboot2_common::Header;
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C, align(8))]
pub struct TagHeader {
pub typ: TagTypeRaw,
pub size: u32,
}
impl TagHeader {
pub fn new(typ: impl Into<TagType>, size: u32) -> Self {
Self {
typ: TagTypeRaw::new(typ.into().val()),
size,
}
}
}
unsafe impl Header for TagHeader {
fn total_size(&self) -> usize {
self.size as usize
}
fn set_size(&mut self, total_size: usize) {
self.size = total_size as u32
}
}