Struct oxygengine::prelude::TypeInfo
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§
§impl TypeInfo
impl TypeInfo
pub fn from_parts(
id: TypeId,
layout: Layout,
drop: unsafe fn(_: *mut u8)
) -> TypeInfo
pub fn from_parts( id: TypeId, layout: Layout, drop: unsafe fn(_: *mut u8) ) -> TypeInfo
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.
pub 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§
§impl Ord for TypeInfo
impl Ord for TypeInfo
§fn cmp(&self, other: &TypeInfo) -> Ordering
fn cmp(&self, other: &TypeInfo) -> Ordering
Order by alignment, descending. Ties broken with TypeId.
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
§impl PartialOrd<TypeInfo> for TypeInfo
impl PartialOrd<TypeInfo> for TypeInfo
§fn partial_cmp(&self, other: &TypeInfo) -> Option<Ordering>
fn partial_cmp(&self, other: &TypeInfo) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for TypeInfo
impl Eq for TypeInfo
Auto Trait Implementations§
impl RefUnwindSafe for TypeInfo
impl Send for TypeInfo
impl Sync for TypeInfo
impl Unpin for TypeInfo
impl UnwindSafe for TypeInfo
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.