Trait multiboot2::TagTrait

source ·
pub trait TagTrait: Pointee {
    const ID: TagType;

    // Required method
    fn dst_size(base_tag: &Tag) -> Self::Metadata;

    // Provided methods
    fn as_base_tag(&self) -> &Tag { ... }
    fn size(&self) -> usize { ... }
    fn as_bytes(&self) -> &[u8] { ... }
    unsafe fn from_base_tag<'a>(tag: &Tag) -> &'a Self { ... }
}
Expand description

A trait to abstract over all sized and unsized tags (DSTs). For sized tags, this trait does not much. For DSTs, a TagTrait::dst_size implementation must me provided, which returns the right size hint for the dynamically sized portion of the struct.

Trivia

This crate uses the Pointee-abstraction of the ptr_meta crate to create fat pointers for tags that are DST.

Required Associated Constants§

source

const ID: TagType

The numeric ID of this tag.

Required Methods§

source

fn dst_size(base_tag: &Tag) -> Self::Metadata

Returns the amount of items in the dynamically sized portion of the DST. Note that this is not the amount of bytes. So if the dynamically sized portion is 16 bytes in size and each element is 4 bytes big, then this function must return 4.

For sized tags, this just returns (). For DSTs, this returns an usize.

Provided Methods§

source

fn as_base_tag(&self) -> &Tag

Returns the tag as the common base tag structure.

source

fn size(&self) -> usize

Returns the total size of the tag. The depends on the size field of the tag.

source

fn as_bytes(&self) -> &[u8]

Returns a slice to the underlying bytes of the tag. This includes all bytes, also for tags that are DSTs. The slice length depends on the size field of the tag.

source

unsafe fn from_base_tag<'a>(tag: &Tag) -> &'a Self

Creates a reference to a (dynamically sized) tag type in a safe way. DST tags need to implement a proper Self::dst_size implementation.

Safety

Callers must be sure that the “size” field of the provided Tag is sane and the underlying memory valid. The implementation of this trait must have a correct Self::dst_size implementation.

Implementors§

source§

impl TagTrait for BasicMemoryInfoTag

source§

const ID: TagType = TagType::BasicMeminfo

source§

impl TagTrait for BootLoaderNameTag

source§

const ID: TagType = TagType::BootLoaderName

source§

impl TagTrait for CommandLineTag

source§

const ID: TagType = TagType::Cmdline

source§

impl TagTrait for EFIBootServicesNotExitedTag

source§

const ID: TagType = TagType::EfiBs

source§

impl TagTrait for EFIImageHandle32Tag

source§

const ID: TagType = TagType::Efi32Ih

source§

impl TagTrait for EFIImageHandle64Tag

source§

const ID: TagType = TagType::Efi64Ih

source§

impl TagTrait for EFIMemoryMapTag

source§

const ID: TagType = TagType::EfiMmap

source§

impl TagTrait for EFISdt32Tag

source§

const ID: TagType = TagType::Efi32

source§

impl TagTrait for EFISdt64Tag

source§

const ID: TagType = TagType::Efi64

source§

impl TagTrait for ElfSectionsTag

source§

const ID: TagType = TagType::ElfSections

source§

impl TagTrait for EndTag

source§

const ID: TagType = TagType::End

source§

impl TagTrait for FramebufferTag

source§

const ID: TagType = TagType::Framebuffer

source§

impl TagTrait for ImageLoadPhysAddrTag

source§

const ID: TagType = TagType::LoadBaseAddr

source§

impl TagTrait for MemoryMapTag

source§

const ID: TagType = TagType::Mmap

source§

impl TagTrait for ModuleTag

source§

const ID: TagType = TagType::Module

source§

impl TagTrait for RsdpV1Tag

source§

const ID: TagType = TagType::AcpiV1

source§

impl TagTrait for RsdpV2Tag

source§

const ID: TagType = TagType::AcpiV2

source§

impl TagTrait for SmbiosTag

source§

const ID: TagType = TagType::Smbios

source§

impl TagTrait for VBEInfoTag

source§

const ID: TagType = TagType::Vbe