pub struct TypeInfo { /* private fields */ }Expand description
Metadata required to store a component.
All told, this means a TypeId, to be able to dynamically name/check the component type; a
Layout, so that we know how to allocate memory for this component type; and a drop function
which internally calls core::ptr::drop_in_place with the correct type parameter.
Implementations§
Source§impl TypeInfo
impl TypeInfo
Sourcepub fn from_parts(id: TypeId, layout: Layout, drop: unsafe fn(*mut u8)) -> Self
pub fn from_parts(id: TypeId, layout: Layout, drop: unsafe fn(*mut u8)) -> Self
Construct a TypeInfo from its components. This is useful in the rare case that you have
some kind of pointer to raw bytes/erased memory holding a component type, coming from a
source unrelated to hecs, and you want to treat it as an insertable component by
implementing the DynamicBundle API.
Sourcepub unsafe fn drop(&self, data: *mut u8)
pub unsafe fn drop(&self, data: *mut u8)
Directly call the destructor on a pointer to data of this component type.
§Safety
All of the caveats of core::ptr::drop_in_place apply, with the additional requirement
that this method is being called on a pointer to an object of the correct component type.
Trait Implementations§
Source§impl Ord for TypeInfo
impl Ord for TypeInfo
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Order by alignment, descending. Ties broken with TypeId.