1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#[derive(Debug)] #[repr(C, packed)] // only repr(C) would add unwanted padding before first_section pub struct BootLoaderNameTag { typ: u32, size: u32, string: u8, } impl BootLoaderNameTag { pub fn name(&self) -> &str { use core::{mem,str,slice}; unsafe { let strlen = self.size as usize - mem::size_of::<BootLoaderNameTag>(); str::from_utf8_unchecked( slice::from_raw_parts((&self.string) as *const u8, strlen)) } } }