Trait GenericWriteStorage

Source
pub trait GenericWriteStorage {
    type Component: Component;
    type AccessMut<'a>: AccessMut<Target = Self::Component>
       where Self: 'a;

    // Required methods
    fn get_mut(
        &mut self,
        entity: Entity,
    ) -> Option<<<Self::Component as Component>::Storage as UnprotectedStorage<Self::Component>>::AccessMut<'_>>;
    fn get_mut_or_default(
        &mut self,
        entity: Entity,
    ) -> Option<<<Self::Component as Component>::Storage as UnprotectedStorage<Self::Component>>::AccessMut<'_>>
       where Self::Component: Default;
    fn insert(
        &mut self,
        entity: Entity,
        comp: Self::Component,
    ) -> InsertResult<Self::Component>;
    fn remove(&mut self, entity: Entity);
    fn _private() -> Seal;
}
Expand description

Provides generic write access to WriteStorage, both as a value and a mutable reference.

Required Associated Types§

Source

type Component: Component

The component type of the storage

Source

type AccessMut<'a>: AccessMut<Target = Self::Component> where Self: 'a

The wrapper through with mutable access of a component is performed.

Required Methods§

Source

fn get_mut( &mut self, entity: Entity, ) -> Option<<<Self::Component as Component>::Storage as UnprotectedStorage<Self::Component>>::AccessMut<'_>>

Get mutable access to an Entitys component

Source

fn get_mut_or_default( &mut self, entity: Entity, ) -> Option<<<Self::Component as Component>::Storage as UnprotectedStorage<Self::Component>>::AccessMut<'_>>
where Self::Component: Default,

Get mutable access to an Entitys component. If the component does not exist, it is automatically created using Default::default().

Returns None if the entity is dead.

Source

fn insert( &mut self, entity: Entity, comp: Self::Component, ) -> InsertResult<Self::Component>

Insert a component for an Entity

Source

fn remove(&mut self, entity: Entity)

Remove the component for an Entity

Source

fn _private() -> Seal

Private function to seal the trait

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.

Implementors§

Source§

impl<'a, T> GenericWriteStorage for WriteStorage<'a, T>
where T: Component,

Source§

type AccessMut<'b> = <<T as Component>::Storage as UnprotectedStorage<T>>::AccessMut<'b> where Self: 'b

Source§

type Component = T

Source§

impl<'a: 'b, 'b, T> GenericWriteStorage for &'b mut WriteStorage<'a, T>
where T: Component,

Source§

type AccessMut<'c> = <<T as Component>::Storage as UnprotectedStorage<T>>::AccessMut<'c> where Self: 'c

Source§

type Component = T