pub struct QueryParamBuilder<T>(/* private fields */);
Expand description
A SystemParamBuilder
for a Query
.
This takes a closure accepting an &mut
QueryBuilder
and uses the builder to construct the query’s state.
This can be used to add additional filters,
or to configure the components available to FilteredEntityRef
or FilteredEntityMut
.
§Example
let system = (QueryParamBuilder::new(|builder| {
builder.with::<Player>();
}),)
.build_state(&mut world)
.build_system(|query: Query<()>| {
for _ in &query {
// This only includes entities with an `Player` component.
}
});
// When collecting multiple builders into a `Vec`,
// use `new_box()` to erase the closure type.
let system = (vec![
QueryParamBuilder::new_box(|builder| {
builder.with::<Player>();
}),
QueryParamBuilder::new_box(|builder| {
builder.without::<Player>();
}),
],)
.build_state(&mut world)
.build_system(|query: Vec<Query<()>>| {});
Implementations§
Source§impl<T> QueryParamBuilder<T>
impl<T> QueryParamBuilder<T>
Sourcepub fn new<D: QueryData, F: QueryFilter>(f: T) -> Selfwhere
T: FnOnce(&mut QueryBuilder<'_, D, F>),
pub fn new<D: QueryData, F: QueryFilter>(f: T) -> Selfwhere
T: FnOnce(&mut QueryBuilder<'_, D, F>),
Creates a SystemParamBuilder
for a Query
that accepts a callback to configure the QueryBuilder
.
Source§impl<'a, D: QueryData, F: QueryFilter> QueryParamBuilder<Box<dyn FnOnce(&mut QueryBuilder<'_, D, F>) + 'a>>
impl<'a, D: QueryData, F: QueryFilter> QueryParamBuilder<Box<dyn FnOnce(&mut QueryBuilder<'_, D, F>) + 'a>>
Sourcepub fn new_box(f: impl FnOnce(&mut QueryBuilder<'_, D, F>) + 'a) -> Self
pub fn new_box(f: impl FnOnce(&mut QueryBuilder<'_, D, F>) + 'a) -> Self
Creates a SystemParamBuilder
for a Query
that accepts a callback to configure the QueryBuilder
.
This boxes the callback so that it has a common type and can be put in a Vec
.
Trait Implementations§
Source§impl<'w, 's, D: QueryData + 'static, F: QueryFilter + 'static, T: FnOnce(&mut QueryBuilder<'_, D, F>)> SystemParamBuilder<Query<'w, 's, D, F>> for QueryParamBuilder<T>
impl<'w, 's, D: QueryData + 'static, F: QueryFilter + 'static, T: FnOnce(&mut QueryBuilder<'_, D, F>)> SystemParamBuilder<Query<'w, 's, D, F>> for QueryParamBuilder<T>
Source§fn build(
self,
world: &mut World,
system_meta: &mut SystemMeta,
) -> QueryState<D, F>
fn build( self, world: &mut World, system_meta: &mut SystemMeta, ) -> QueryState<D, F>
Registers any
World
access used by this SystemParam
and creates a new instance of this param’s State
.Source§fn build_state(self, world: &mut World) -> SystemState<P>
fn build_state(self, world: &mut World) -> SystemState<P>
Create a
SystemState
from a SystemParamBuilder
.
To create a system, call SystemState::build_system
on the result.Auto Trait Implementations§
impl<T> Freeze for QueryParamBuilder<T>where
T: Freeze,
impl<T> RefUnwindSafe for QueryParamBuilder<T>where
T: RefUnwindSafe,
impl<T> Send for QueryParamBuilder<T>where
T: Send,
impl<T> Sync for QueryParamBuilder<T>where
T: Sync,
impl<T> Unpin for QueryParamBuilder<T>where
T: Unpin,
impl<T> UnwindSafe for QueryParamBuilder<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.