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 a `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<T: Clone> Clone for QueryParamBuilder<T>
impl<T: Clone> Clone for QueryParamBuilder<T>
Source§fn clone(&self) -> QueryParamBuilder<T>
fn clone(&self) -> QueryParamBuilder<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§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) -> QueryState<D, F>
fn build(self, world: &mut World) -> 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn 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>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which 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)
Converts
&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)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of this value.