pub trait ComponentInstance {
// Required methods
fn get_instance<T>(&self, entity: Entity) -> Option<InstanceRef<'_, T>>
where T: Component;
fn get_instance_mut<T>(
&mut self,
entity: Entity,
) -> Option<InstanceMut<'_, T>>
where T: Component<Mutability = Mutable>;
// Provided methods
fn instance<T>(&self, instance: Instance<T>) -> InstanceRef<'_, T>
where T: Component { ... }
fn instance_mut<T>(&mut self, instance: Instance<T>) -> InstanceMut<'_, T>
where T: Component<Mutability = Mutable> { ... }
}Expand description
Extension trait used to get Component data from an Instance<T> via World.
Required Methods§
Sourcefn get_instance<T>(&self, entity: Entity) -> Option<InstanceRef<'_, T>>where
T: Component,
fn get_instance<T>(&self, entity: Entity) -> Option<InstanceRef<'_, T>>where
T: Component,
Returns a reference to the given instance, if it is of Kind T.
Sourcefn get_instance_mut<T>(&mut self, entity: Entity) -> Option<InstanceMut<'_, T>>
fn get_instance_mut<T>(&mut self, entity: Entity) -> Option<InstanceMut<'_, T>>
Provided Methods§
Sourcefn instance<T>(&self, instance: Instance<T>) -> InstanceRef<'_, T>where
T: Component,
fn instance<T>(&self, instance: Instance<T>) -> InstanceRef<'_, T>where
T: Component,
Returns a reference to the given instance.
§Panics
If the given instance is not a valid entity of kind T.
Sourcefn instance_mut<T>(&mut self, instance: Instance<T>) -> InstanceMut<'_, T>
fn instance_mut<T>(&mut self, instance: Instance<T>) -> InstanceMut<'_, T>
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.