pub trait WorldQuery {
type Item<'a>;
// Required methods
fn type_ids() -> Vec<TypeId>;
unsafe fn fetch<'a>(
page_ptr: *const ComponentPage,
row_index: usize,
) -> Self::Item<'a>;
// Provided method
fn without_type_ids() -> Vec<TypeId> { ... }
}Expand description
A trait implemented by types that can be used to query data from the World.
This “sealed” trait provides the necessary information for the query engine to
find the correct pages and safely access component data. It is implemented for
component references (&T, &mut T), EntityId, filters like Without<T>,
and tuples of other WorldQuery types.
Required Associated Types§
Required Methods§
Sourcefn type_ids() -> Vec<TypeId>
fn type_ids() -> Vec<TypeId>
Returns the sorted list of TypeIds for the components to be INCLUDED in the query.
This signature is used to find ComponentPages that contain all these components.
Sourceunsafe fn fetch<'a>(
page_ptr: *const ComponentPage,
row_index: usize,
) -> Self::Item<'a>
unsafe fn fetch<'a>( page_ptr: *const ComponentPage, row_index: usize, ) -> Self::Item<'a>
Fetches the query’s item from a specific row in a ComponentPage.
§Safety
This function is unsafe because the caller (the Query iterator) must guarantee
several invariants:
- The page pointed to by
page_ptris valid and matches the query’s signature. row_indexis a valid index within the page’s columns.- Aliasing rules are not violated (e.g., no two
&mut Tto the same data).
Provided Methods§
Sourcefn without_type_ids() -> Vec<TypeId>
fn without_type_ids() -> Vec<TypeId>
Returns the sorted list of TypeIds for components to be EXCLUDED from the query.
Used to filter out pages that contain these components.
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 WorldQuery for EntityId
impl WorldQuery for EntityId
Source§impl<Q1: WorldQuery> WorldQuery for (Q1,)
impl<Q1: WorldQuery> WorldQuery for (Q1,)
Source§impl<Q1: WorldQuery, Q2: WorldQuery> WorldQuery for (Q1, Q2)
impl<Q1: WorldQuery, Q2: WorldQuery> WorldQuery for (Q1, Q2)
Source§impl<Q1: WorldQuery, Q2: WorldQuery, Q3: WorldQuery> WorldQuery for (Q1, Q2, Q3)
impl<Q1: WorldQuery, Q2: WorldQuery, Q3: WorldQuery> WorldQuery for (Q1, Q2, Q3)
Source§impl<Q1: WorldQuery, Q2: WorldQuery, Q3: WorldQuery, Q4: WorldQuery> WorldQuery for (Q1, Q2, Q3, Q4)
impl<Q1: WorldQuery, Q2: WorldQuery, Q3: WorldQuery, Q4: WorldQuery> WorldQuery for (Q1, Q2, Q3, Q4)
type Item<'a> = (<Q1 as WorldQuery>::Item<'a>, <Q2 as WorldQuery>::Item<'a>, <Q3 as WorldQuery>::Item<'a>, <Q4 as WorldQuery>::Item<'a>)
fn type_ids() -> Vec<TypeId>
fn without_type_ids() -> Vec<TypeId>
unsafe fn fetch<'a>( page_ptr: *const ComponentPage, row_index: usize, ) -> Self::Item<'a>
Source§impl<T: Component> WorldQuery for &T
impl<T: Component> WorldQuery for &T
Source§unsafe fn fetch<'a>(
page_ptr: *const ComponentPage,
row_index: usize,
) -> Self::Item<'a>
unsafe fn fetch<'a>( page_ptr: *const ComponentPage, row_index: usize, ) -> Self::Item<'a>
Fetches a reference to the component T from the specified row.
§Safety
The caller MUST guarantee that the page contains a column for component T
and that row_index is in bounds.
type Item<'a> = &'a T
fn type_ids() -> Vec<TypeId>
Source§impl<T: Component> WorldQuery for &mut T
impl<T: Component> WorldQuery for &mut T
Source§unsafe fn fetch<'a>(
page_ptr: *const ComponentPage,
row_index: usize,
) -> Self::Item<'a>
unsafe fn fetch<'a>( page_ptr: *const ComponentPage, row_index: usize, ) -> Self::Item<'a>
Fetches a mutable reference to the component T from the specified row.
§Safety
The caller MUST guarantee that:
- The page contains a column for component
T. row_indexis in bounds.- No other mutable reference to this specific component exists at the same time. The query engine must enforce this.