Struct bevy::ecs::query::FilteredAccess
pub struct FilteredAccess<T>where
T: SparseSetIndex,{ /* private fields */ }
Expand description
An Access
that has been filtered to include and exclude certain combinations of elements.
Used internally to statically check if queries are disjoint.
Subtle: a read
or write
in access
should not be considered to imply a
with
access.
For example consider Query<Option<&T>>
this only has a read
of T
as doing
otherwise would allow for queries to be considered disjoint when they shouldn’t:
Query<(&mut T, Option<&U>)>
read/writeT
, readU
, withU
Query<&mut T, Without<U>>
read/writeT
, withoutU
from this we could reasonably conclude that the queries are disjoint but they aren’t.
In order to solve this the actual access that Query<(&mut T, Option<&U>)>
has
is read/write T
, read U
. It must still have a read U
access otherwise the following
queries would be incorrectly considered disjoint:
Query<&mut T>
read/writeT
Query<Option<&T>>
accesses nothing
See comments the WorldQuery
impls of AnyOf
/Option
/Or
for more information.
Implementations§
§impl<T> FilteredAccess<T>where
T: SparseSetIndex,
impl<T> FilteredAccess<T>where T: SparseSetIndex,
pub fn access_mut(&mut self) -> &mut Access<T>
pub fn access_mut(&mut self) -> &mut Access<T>
Returns a mutable reference to the underlying unfiltered access.
pub fn add_read(&mut self, index: T)
pub fn add_read(&mut self, index: T)
Adds access to the element given by index
.
pub fn add_write(&mut self, index: T)
pub fn add_write(&mut self, index: T)
Adds exclusive access to the element given by index
.
pub fn and_with(&mut self, index: T)
pub fn and_with(&mut self, index: T)
Adds a With
filter: corresponds to a conjunction (AND) operation.
Suppose we begin with Or<(With<A>, With<B>)>
, which is represented by an array of two AccessFilter
instances.
Adding AND With<C>
via this method transforms it into the equivalent of Or<((With<A>, With<C>), (With<B>, With<C>))>
.
pub fn and_without(&mut self, index: T)
pub fn and_without(&mut self, index: T)
Adds a Without
filter: corresponds to a conjunction (AND) operation.
Suppose we begin with Or<(With<A>, With<B>)>
, which is represented by an array of two AccessFilter
instances.
Adding AND Without<C>
via this method transforms it into the equivalent of Or<((With<A>, Without<C>), (With<B>, Without<C>))>
.
pub fn append_or(&mut self, other: &FilteredAccess<T>)
pub fn append_or(&mut self, other: &FilteredAccess<T>)
Appends an array of filters: corresponds to a disjunction (OR) operation.
As the underlying array of filters represents a disjunction,
where each element (AccessFilters
) represents a conjunction,
we can simply append to the array.
pub fn extend_access(&mut self, other: &FilteredAccess<T>)
pub fn extend_access(&mut self, other: &FilteredAccess<T>)
Adds all of the accesses from other
to self
.
pub fn is_compatible(&self, other: &FilteredAccess<T>) -> bool
pub fn is_compatible(&self, other: &FilteredAccess<T>) -> bool
Returns true
if this and other
can be active at the same time.
pub fn get_conflicts(&self, other: &FilteredAccess<T>) -> Vec<T, Global>
pub fn get_conflicts(&self, other: &FilteredAccess<T>) -> Vec<T, Global>
Returns a vector of elements that this and other
cannot access at the same time.
pub fn extend(&mut self, other: &FilteredAccess<T>)
pub fn extend(&mut self, other: &FilteredAccess<T>)
Adds all access and filters from other
.
Corresponds to a conjunction operation (AND) for filters.
Extending Or<(With<A>, Without<B>)>
with Or<(With<C>, Without<D>)>
will result in
Or<((With<A>, With<C>), (With<A>, Without<D>), (Without<B>, With<C>), (Without<B>, Without<D>))>
.
pub fn read_all(&mut self)
pub fn read_all(&mut self)
Sets the underlying unfiltered access as having access to all indexed elements.
pub fn write_all(&mut self)
pub fn write_all(&mut self)
Sets the underlying unfiltered access as having mutable access to all indexed elements.
Trait Implementations§
§impl<T> Clone for FilteredAccess<T>where
T: Clone + SparseSetIndex,
impl<T> Clone for FilteredAccess<T>where T: Clone + SparseSetIndex,
§fn clone(&self) -> FilteredAccess<T>
fn clone(&self) -> FilteredAccess<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl<T> Debug for FilteredAccess<T>where
T: Debug + SparseSetIndex,
impl<T> Debug for FilteredAccess<T>where T: Debug + SparseSetIndex,
§impl<T> Default for FilteredAccess<T>where
T: SparseSetIndex,
impl<T> Default for FilteredAccess<T>where T: SparseSetIndex,
§fn default() -> FilteredAccess<T>
fn default() -> FilteredAccess<T>
§impl<T> From<FilteredAccess<T>> for FilteredAccessSet<T>where
T: SparseSetIndex,
impl<T> From<FilteredAccess<T>> for FilteredAccessSet<T>where T: SparseSetIndex,
§fn from(filtered_access: FilteredAccess<T>) -> FilteredAccessSet<T>
fn from(filtered_access: FilteredAccess<T>) -> FilteredAccessSet<T>
§impl<T> PartialEq<FilteredAccess<T>> for FilteredAccess<T>where
T: PartialEq<T> + SparseSetIndex,
impl<T> PartialEq<FilteredAccess<T>> for FilteredAccess<T>where T: PartialEq<T> + SparseSetIndex,
§fn eq(&self, other: &FilteredAccess<T>) -> bool
fn eq(&self, other: &FilteredAccess<T>) -> bool
self
and other
values to be equal, and is used
by ==
.impl<T> Eq for FilteredAccess<T>where T: Eq + SparseSetIndex,
impl<T> StructuralEq for FilteredAccess<T>where T: SparseSetIndex,
impl<T> StructuralPartialEq for FilteredAccess<T>where T: SparseSetIndex,
Auto Trait Implementations§
impl<T> RefUnwindSafe for FilteredAccess<T>where T: RefUnwindSafe,
impl<T> Send for FilteredAccess<T>where T: Send,
impl<T> Sync for FilteredAccess<T>where T: Sync,
impl<T> Unpin for FilteredAccess<T>where T: Unpin,
impl<T> UnwindSafe for FilteredAccess<T>where T: UnwindSafe,
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
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
.§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given World
.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for Pwhere
R: Read + ReadEndian<P>,
P: Default,
impl<R, P> ReadPrimitive<R> for Pwhere R: Read + ReadEndian<P>, P: Default,
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.