ComponentInstance

Trait ComponentInstance 

Source
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§

Source

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.

Source

fn get_instance_mut<T>(&mut self, entity: Entity) -> Option<InstanceMut<'_, T>>
where T: Component<Mutability = Mutable>,

Returns a mutable reference to the given instance, if it is of Kind T.

This requires T to be Mutable.

Provided Methods§

Source

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.

Source

fn instance_mut<T>(&mut self, instance: Instance<T>) -> InstanceMut<'_, T>
where T: Component<Mutability = Mutable>,

Returns a mutable reference to the given instance.

This requires T to be Mutable.

§Panics

If the given instance is not a valid entity of kind 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.

Implementations on Foreign Types§

Source§

impl ComponentInstance for DeferredWorld<'_>

Source§

fn get_instance<T>(&self, entity: Entity) -> Option<InstanceRef<'_, T>>
where T: Component,

Source§

fn get_instance_mut<T>(&mut self, entity: Entity) -> Option<InstanceMut<'_, T>>
where T: Component<Mutability = Mutable>,

Source§

impl ComponentInstance for World

Source§

fn get_instance<T>(&self, entity: Entity) -> Option<InstanceRef<'_, T>>
where T: Component,

Source§

fn get_instance_mut<T>(&mut self, entity: Entity) -> Option<InstanceMut<'_, T>>
where T: Component<Mutability = Mutable>,

Implementors§