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

    // Provided method
    fn to_empty(&self) -> SubWorldRaw<&World, ()> { ... }
}
Expand description

Trait for allowing function to work on both World and SubWorld

Required Methods§

source

fn to_ref<T>(&self) -> SubWorldRaw<&World, T>

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

source

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

Queries the world

source

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

Queries the world for a specific entity

source

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

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>(&self, entity: Entity) -> Result<RefMut<'_, C>, Error>
where C: Component,

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) -> SubWorldRaw<&World, ()>

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

Object Safety§

This trait is not object safe.

Implementors§

source§

impl GenericWorld for World

source§

impl<A, T> GenericWorld for SubWorldRaw<A, T>
where A: Deref<Target = World>, T: ComponentBorrow,