pub struct DataComponentType<T> {
pub key: Identifier,
_phantom: PhantomData<T>,
}Expand description
A typed handle for a data component.
This provides compile-time type safety when getting/setting components.
The actual storage uses ComponentData for ABI stability.
§Example
ⓘ
pub const DAMAGE: DataComponentType<Damage> =
DataComponentType::new(Identifier::vanilla_static("damage"));
// Type-safe access
let damage: Option<Damage> = components.get(DAMAGE);
components.set(DAMAGE, Damage(10));Fields§
§key: Identifier§_phantom: PhantomData<T>Implementations§
Source§impl<T> DataComponentType<T>
impl<T> DataComponentType<T>
pub const fn new(key: Identifier) -> Self
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for DataComponentType<T>
impl<T> RefUnwindSafe for DataComponentType<T>where
T: RefUnwindSafe,
impl<T> Send for DataComponentType<T>where
T: Send,
impl<T> Sync for DataComponentType<T>where
T: Sync,
impl<T> Unpin for DataComponentType<T>where
T: Unpin,
impl<T> UnsafeUnpin for DataComponentType<T>
impl<T> UnwindSafe for DataComponentType<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more