Trait multiboot2::TagTrait
source · pub trait TagTrait: Pointee {
// Required method
fn dst_size(base_tag: &Tag) -> Self::Metadata;
// Provided method
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.
The TagTrait::from_base_tag
method has a default implementation for all
tags that are Sized
.
Trivia
This crate uses the Pointee
-abstraction of the ptr_meta
crate to
create fat pointers.
Required Methods§
Provided Methods§
sourceunsafe fn from_base_tag<'a>(tag: &Tag) -> &'a Self
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.
Object Safety§
This trait is not object safe.