Skip to main content

QueryBuilder

Struct QueryBuilder 

Source
pub struct QueryBuilder<'w, Q: WorldQuery, F: QueryFilter = ()> { /* private fields */ }
Expand description

Builder for constructing and executing queries.

Created by World::query(). Chain .with::<T>() and .without::<T>() to add filters, then call .iter() or .get(id) to execute.

Implementations§

Source§

impl<'w, Q: WorldQuery, F: QueryFilter> QueryBuilder<'w, Q, F>

Source

pub const fn with<T: 'static>(self) -> QueryBuilder<'w, Q, (F, With<T>)>
where (F, With<T>): QueryFilter,

Add a With<T> filter — only match entities that have built-in component T.

Source

pub const fn without<T: 'static>(self) -> QueryBuilder<'w, Q, (F, Without<T>)>
where (F, Without<T>): QueryFilter,

Add a Without<T> filter — exclude entities that have built-in component T.

Source

pub const fn ext_with<T: 'static + Send + Sync>( self, ) -> QueryBuilder<'w, Q, (F, ExtWith<T>)>
where (F, ExtWith<T>): QueryFilter,

Add an ExtWith<T> filter — only match entities with extension component T.

Source

pub const fn ext_without<T: 'static + Send + Sync>( self, ) -> QueryBuilder<'w, Q, (F, ExtWithout<T>)>
where (F, ExtWithout<T>): QueryFilter,

Add an ExtWithout<T> filter — exclude entities with extension component T.

Source

pub fn iter(self) -> QueryIter<'w, Q, F>

Execute the query and iterate matching entities.

Source

pub fn get(self, id: EntityId) -> Option<Q::Item<'w>>

Fetch a single entity by ID.

Auto Trait Implementations§

§

impl<'w, Q, F> Freeze for QueryBuilder<'w, Q, F>

§

impl<'w, Q, F = ()> !RefUnwindSafe for QueryBuilder<'w, Q, F>

§

impl<'w, Q, F> Send for QueryBuilder<'w, Q, F>
where Q: Send, F: Send,

§

impl<'w, Q, F> Sync for QueryBuilder<'w, Q, F>
where Q: Sync, F: Sync,

§

impl<'w, Q, F> Unpin for QueryBuilder<'w, Q, F>
where Q: Unpin, F: Unpin,

§

impl<'w, Q, F> UnsafeUnpin for QueryBuilder<'w, Q, F>

§

impl<'w, Q, F = ()> !UnwindSafe for QueryBuilder<'w, Q, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.