pub trait GenericWorld {
    // Required methods
    fn to_ref<T: ComponentBorrow + Subset>(&self) -> SubWorldRef<'_, T>;
    fn try_query<Q: Query + Subset>(&self) -> Result<QueryBorrow<'_, Q>>;
    fn try_query_one<Q: Query + Subset>(
        &self,
        entity: Entity
    ) -> Result<QueryOne<'_, Q>>;
    fn try_get<C: Component>(&self, entity: Entity) -> Result<Ref<'_, C>>;
    fn try_get_mut<C: Component>(&self, entity: Entity) -> Result<RefMut<'_, C>>;
    fn reserve(&self) -> Entity;

    // Provided method
    fn to_empty(&self) -> EmptyWorld<'_> { ... }
}
Expand description

Trait for allowing function to work on both World and SubWorld

Required Methods§

source

fn to_ref<T: ComponentBorrow + Subset>(&self) -> SubWorldRef<'_, T>

Convert the subworld into another holding an internal reference to the original world.

source

fn try_query<Q: Query + Subset>(&self) -> Result<QueryBorrow<'_, Q>>

Queries the world

source

fn try_query_one<Q: Query + Subset>( &self, entity: Entity ) -> Result<QueryOne<'_, Q>>

Queries the world for a specific entity

source

fn try_get<C: Component>(&self, entity: Entity) -> Result<Ref<'_, C>>

Get a single component for an entity Returns the contextual result since hecs-schedule is required to be imported anyway

source

fn try_get_mut<C: Component>(&self, entity: Entity) -> Result<RefMut<'_, C>>

Get a single component for an entity Returns the contextual result since hecs-schedule is required to be imported anyway

source

fn reserve(&self) -> Entity

Reserve an entity

Provided Methods§

source

fn to_empty(&self) -> EmptyWorld<'_>

Transform this into a subworld which borrows no components. This is useful for concurrent access of entities.

Implementations on Foreign Types§

source§

impl GenericWorld for World

source§

fn reserve(&self) -> Entity

Reserve an entity

source§

fn to_ref<T: ComponentBorrow + Subset>(&self) -> SubWorldRef<'_, T>

source§

fn try_query<Q: Query + Subset>(&self) -> Result<QueryBorrow<'_, Q>>

source§

fn try_query_one<Q: Query + Subset>( &self, entity: Entity ) -> Result<QueryOne<'_, Q>>

source§

fn try_get<C: Component>(&self, entity: Entity) -> Result<Ref<'_, C>>

source§

fn try_get_mut<C: Component>(&self, entity: Entity) -> Result<RefMut<'_, C>>

Implementors§