pub struct ReflectQueryable(/* private fields */);Expand description
A reflect trait extending ReflectComponent with query methods.
ReflectComponent doesn’t have methods to get
Implementations§
Source§impl ReflectQueryable
impl ReflectQueryable
Sourcepub const fn get(&self) -> &ReflectQueryableFns
pub const fn get(&self) -> &ReflectQueryableFns
Return the function pointers implementing the ReflectQueryable methods.
Source§impl ReflectQueryable
Get a single entity with the reflected queryable Component.
impl ReflectQueryable
Get a single entity with the reflected queryable Component.
Sourcepub fn get_single<'a>(
&self,
world: &'a mut World,
) -> Result<&'a dyn Reflect, QuerySingleError>
pub fn get_single<'a>( &self, world: &'a mut World, ) -> Result<&'a dyn Reflect, QuerySingleError>
Get a single &dyn Reflect of the underyling
Component from World, failing if there isn’t exactly one Entity
matching this description.
Consider using ReflectQueryable::query followed
by .next() if you want to get a value even if there is more than one
Entity with the underlying Component.
§Errors
This will return an Err if:
- There is no
Entitywith the underylingComponentinworld. - There is more than one
Entitywith the underylingComponentinworld.
Sourcepub fn get_single_ref<'a>(
&self,
world: &'a mut World,
) -> Result<Ref<'a, dyn Reflect>, QuerySingleError>
pub fn get_single_ref<'a>( &self, world: &'a mut World, ) -> Result<Ref<'a, dyn Reflect>, QuerySingleError>
Get a single Ref<dyn Reflect> of the underyling
Component from World, failing if there isn’t exactly one Entity
matching this description.
Consider using ReflectQueryable::query_ref followed
by .next() if you want to get a value even if there is more than one
Entity with the underlying Component.
§Errors
This will return an Err if:
- There is no
Entitywith the underylingComponentinworld. - There is more than one
Entitywith the underylingComponentinworld.
Sourcepub fn get_single_mut<'a>(
&self,
world: &'a mut World,
) -> Result<Mut<'a, dyn Reflect>, QuerySingleError>
pub fn get_single_mut<'a>( &self, world: &'a mut World, ) -> Result<Mut<'a, dyn Reflect>, QuerySingleError>
Get a single Mut<dyn Reflect> of the underyling
Component from World, failing if there isn’t exactly one Entity
matching this description.
Consider using ReflectQueryable::query_mut followed
by .next() if you want to get a value even if there is more than one
Entity with the underlying Component.
§Errors
This will return an Err if:
- There is no
Entitywith the underylingComponentinworld. - There is more than one
Entitywith the underylingComponentinworld.
Sourcepub fn get_single_entity(
&self,
world: &mut World,
) -> Result<Entity, QuerySingleError>
pub fn get_single_entity( &self, world: &mut World, ) -> Result<Entity, QuerySingleError>
Get a single Entity of the underyling
Component from World, failing if there isn’t exactly one Entity
matching this description.
Consider using ReflectQueryable::query_entities followed
by .next() if you want to get a value even if there is more than one
Entity with the underlying Component.
§Errors
This will return an Err if:
- There is no
Entitywith the underylingComponentinworld. - There is more than one
Entitywith the underylingComponentinworld.
Source§impl ReflectQueryable
Query all entities with the reflected queryable Component.
impl ReflectQueryable
Query all entities with the reflected queryable Component.
Sourcepub fn query(&self, world: &mut World) -> Querydyn
pub fn query(&self, world: &mut World) -> Querydyn
Get a Querydyn to iterate over all
&dyn Reflect with the underlying
Component from world.
Use ReflectQueryable::get_single for a version that returns
a single element directly.
§Example
use std::any::TypeId;
use bevy::prelude::{Reflect, ReflectComponent, Component, World};
use bevy::reflect::TypeRegistryInternal as TypeRegistry;
use cuicui_reflect_query::ReflectQueryable;
#[derive(Component, Reflect, Default)]
#[reflect(Component, Queryable)]
struct Zoobazee {
bee: u32,
baboo: String,
}
fn reflect_query(world: &mut World, registry: &TypeRegistry) {
let type_data = registry
.get_type_data::<ReflectQueryable>(TypeId::of::<Zoobazee>())
.unwrap();
let mut query = type_data.query(world);
for element in query.iter(world) {
println!("{element:?}");
}
}Sourcepub fn query_entities(&self, world: &mut World) -> EntityQuerydyn
pub fn query_entities(&self, world: &mut World) -> EntityQuerydyn
Get a EntityQuerydyn to iterate over all
Entity with the underlying
Component from world.
Use ReflectQueryable::get_single_entity for a version that returns
a single element directly.
§Example
use std::any::TypeId;
use bevy::prelude::{Reflect, ReflectComponent, Component, World};
use bevy::reflect::TypeRegistryInternal as TypeRegistry;
use cuicui_reflect_query::ReflectQueryable;
#[derive(Component, Reflect, Default)]
#[reflect(Component, Queryable)]
struct Zoobazee {
bee: u32,
baboo: String,
}
fn reflect_query(world: &mut World, registry: &TypeRegistry) {
let type_data = registry
.get_type_data::<ReflectQueryable>(TypeId::of::<Zoobazee>())
.unwrap();
let mut query = type_data.query_entities(world);
for element in query.iter(world) {
println!("{element:?}");
}
}Sourcepub fn query_ref(&self, world: &mut World) -> RefQuerydyn
pub fn query_ref(&self, world: &mut World) -> RefQuerydyn
Get a RefQuerydyn to iterate over all
Ref<dyn Reflect> with the underlying
Component from world.
Use ReflectQueryable::get_single_ref for a version that returns
a single element directly.
§Example
use std::any::TypeId;
use bevy::prelude::{Reflect, ReflectComponent, Component, World};
use bevy::reflect::TypeRegistryInternal as TypeRegistry;
use cuicui_reflect_query::ReflectQueryable;
#[derive(Component, Reflect, Default)]
#[reflect(Component, Queryable)]
struct Zoobazee {
bee: u32,
baboo: String,
}
fn reflect_query(world: &mut World, registry: &TypeRegistry) {
let type_data = registry
.get_type_data::<ReflectQueryable>(TypeId::of::<Zoobazee>())
.unwrap();
let mut query = type_data.query_ref(world);
for element in query.iter(world) {
println!("{element:?}");
}
}Sourcepub fn query_mut(&self, world: &mut World) -> MutQuerydyn
pub fn query_mut(&self, world: &mut World) -> MutQuerydyn
Get a MutQuerydyn to iterate over all
Mut<dyn Reflect> with the underlying
Component from world.
Use ReflectQueryable::get_single_mut for a version that returns
a single element directly.
§Example
use std::any::TypeId;
use bevy::prelude::{Reflect, ReflectComponent, Component, World};
use bevy::reflect::TypeRegistryInternal as TypeRegistry;
use cuicui_reflect_query::ReflectQueryable;
#[derive(Component, Reflect, Default)]
#[reflect(Component, Queryable)]
struct Zoobazee {
bee: u32,
baboo: String,
}
fn reflect_query(world: &mut World, registry: &TypeRegistry) {
let type_data = registry
.get_type_data::<ReflectQueryable>(TypeId::of::<Zoobazee>())
.unwrap();
let mut query = type_data.query_mut(world);
for element in query.iter(world) {
println!("{element:?}");
}
}Trait Implementations§
Source§impl Clone for ReflectQueryable
impl Clone for ReflectQueryable
Source§fn clone(&self) -> ReflectQueryable
fn clone(&self) -> ReflectQueryable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ReflectQueryable
impl RefUnwindSafe for ReflectQueryable
impl Send for ReflectQueryable
impl Sync for ReflectQueryable
impl Unpin for ReflectQueryable
impl UnwindSafe for ReflectQueryable
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
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.