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