pub trait Entity: Any + Default {
// Required methods
fn id() -> usize;
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
// Provided methods
fn name() -> &'static str { ... }
fn type_id() -> TypeId { ... }
fn property_ids() -> &'static [TypeId] { ... }
fn required_property_ids() -> &'static [TypeId] { ... }
fn new_boxed() -> Box<Self> { ... }
}Expand description
All entities must implement this trait using the define_entity! macro.
Required Methods§
Sourcefn id() -> usize
fn id() -> usize
The index of this item in the owner, which is initialized globally per type
upon first access. We explicitly initialize this in a ctor in order to know
how many Entity types exist globally when we construct any EntityStore.
fn as_any_mut(&mut self) -> &mut dyn Any
Provided Methods§
fn name() -> &'static str
fn type_id() -> TypeId
Sourcefn property_ids() -> &'static [TypeId]
fn property_ids() -> &'static [TypeId]
Get a list of all properties this Entity has. This list is static, computed in with ctor magic.
Sourcefn required_property_ids() -> &'static [TypeId]
fn required_property_ids() -> &'static [TypeId]
Get a list of all properties of this Entity that must be supplied when a new entity is created.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.