Struct rin::ecs::operators::Ref [−][src]
pub struct Ref<'a, T, R> where
T: NToOneComponent<'a>, { /* fields omitted */ }
Applies a component in another entity referenced through a component that Derefs to an Entity:
Entity A Entity C
Component(Entity) ───────────────► AnotherCompoenent
▲
│
Entity B │
Component(Entity) ──────────────────┘
Allows to create NToOne relations between entities components.
When the referenced operator accesses the component mutably, an iterator over Ref will return
a StreamingIterator
which can’t be used in for loops and instead has to be used with
.for_each
or .for_each_mut
. The operations available on this iterators are also limited.
This is to ensure that two or more mutable references to the same data won’t be kept
simultaneously. If you are only using the iterator in a for loop or similar and not keeping the
returned mutable references then any of the unsafe_iter_mut
methods in entities or storages
can be used safely.
In the following example we create 2 entities that share a common geometry then access the geometry for each entity:
#[derive(Debug)] struct Vertex; #[derive(NToOneComponent, Debug)] struct GeometryRef(Entity); #[derive(Component, Debug)] struct Geometry(Vec<Vertex>); #[derive(Component, Debug)] struct Position{x: f32, y: f32}; let mut world = World::new(); let geometry = world.new_entity().add(Geometry(vec![Vertex, Vertex, Vertex])).build(); let a = world.new_entity() .add(GeometryRef(geometry)) .add(Position{x: 0.0, y: 0.0}) .build(); let b = world.new_entity() .add(GeometryRef(geometry)) .add(Position{x: 0.0, y: 0.0}) .build(); let entities = world.entities(); for geometry in entities.iter_for::<Ref<GeometryRef, Read<Geometry>>>() { }
Trait Implementations
impl<'a, T, R> DataAccesses for Ref<'a, T, R> where
T: NToOneComponent<'a>,
R: DataAccesses,
[src]
impl<'a, T, R> DataAccesses for Ref<'a, T, R> where
T: NToOneComponent<'a>,
R: DataAccesses,
[src]impl<'a, T, R> Deref for Ref<'a, T, R> where
T: NToOneComponent<'a>,
R: UnorderedData<'a>,
[src]
impl<'a, T, R> Deref for Ref<'a, T, R> where
T: NToOneComponent<'a>,
R: UnorderedData<'a>,
[src]impl<'a, T, R> DerefMut for Ref<'a, T, R> where
T: NToOneComponent<'a>,
R: UnorderedData<'a>,
[src]
impl<'a, T, R> DerefMut for Ref<'a, T, R> where
T: NToOneComponent<'a>,
R: UnorderedData<'a>,
[src]impl<'a, T, R> FromComponent<'a, <R as UnorderedData<'a>>::ComponentsRef> for Ref<'a, T, R> where
T: NToOneComponent<'a>,
R: UnorderedData<'a> + FromComponent<'a, <R as UnorderedData<'a>>::ComponentsRef>,
[src]
impl<'a, T, R> FromComponent<'a, <R as UnorderedData<'a>>::ComponentsRef> for Ref<'a, T, R> where
T: NToOneComponent<'a>,
R: UnorderedData<'a> + FromComponent<'a, <R as UnorderedData<'a>>::ComponentsRef>,
[src]pub fn from_component(
component: <R as UnorderedData<'a>>::ComponentsRef
) -> Ref<'a, T, R>
[src]
component: <R as UnorderedData<'a>>::ComponentsRef
) -> Ref<'a, T, R>
impl<'a, T, R> UnorderedData<'a> for Ref<'a, T, R> where
T: Deref<Target = Entity> + NToOneComponent<'a>,
R: UnorderedData<'a>,
<T as Component>::Storage: for<'s> Storage<'s, T>,
<<T as Component>::Storage as Storage<'a, T>>::Get: Borrow<T>,
[src]
impl<'a, T, R> UnorderedData<'a> for Ref<'a, T, R> where
T: Deref<Target = Entity> + NToOneComponent<'a>,
R: UnorderedData<'a>,
<T as Component>::Storage: for<'s> Storage<'s, T>,
<<T as Component>::Storage as Storage<'a, T>>::Get: Borrow<T>,
[src]type Iter = RefIter<'a, <Ref<'a, T, R> as UnorderedData<'a>>::Storage>
type IterMut = RefIterMut<'a, <Ref<'a, T, R> as UnorderedData<'a>>::Storage, <Ref<'a, T, R> as UnorderedData<'a>>::ComponentsRef>
type Components = <R as UnorderedData<'a>>::Components
type ComponentsRef = <R as UnorderedData<'a>>::ComponentsRef
type Storage = RefStorage<'a, ReadGuardRef<'a, <T as Component>::Storage>, T, <R as UnorderedData<'a>>::Storage, <R as UnorderedData<'a>>::Components, RefData, LazyIndexGuard<'a>>
pub fn query_mask<E>(entities: &E) -> Bitmask where
E: EntitiesStorage,
[src]
E: EntitiesStorage,
pub fn into_iter<E>(
entities: &'a E
) -> <Ref<'a, T, R> as UnorderedData<'a>>::Iter where
E: EntitiesStorage,
[src]
entities: &'a E
) -> <Ref<'a, T, R> as UnorderedData<'a>>::Iter where
E: EntitiesStorage,
pub fn into_iter_mut<E>(
entities: &'a E
) -> <Ref<'a, T, R> as UnorderedData<'a>>::IterMut where
E: EntitiesStorage,
[src]
entities: &'a E
) -> <Ref<'a, T, R> as UnorderedData<'a>>::IterMut where
E: EntitiesStorage,
pub fn storage<E>(
entities: &'a E
) -> Option<<Ref<'a, T, R> as UnorderedData<'a>>::Storage> where
E: EntitiesStorage,
[src]
entities: &'a E
) -> Option<<Ref<'a, T, R> as UnorderedData<'a>>::Storage> where
E: EntitiesStorage,
impl<'a, T, R> SafeIter<'a> for Ref<'a, T, R> where
T: NToOneComponent<'a>,
R: ReadOnlyOp<'a>,
[src]
T: NToOneComponent<'a>,
R: ReadOnlyOp<'a>,
impl<'a, T, R> SafeStreamingIter<'a> for Ref<'a, T, R> where
T: NToOneComponent<'a>,
[src]
T: NToOneComponent<'a>,
Auto Trait Implementations
impl<'a, T, R> RefUnwindSafe for Ref<'a, T, R> where
R: RefUnwindSafe,
T: RefUnwindSafe,
R: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, R> Send for Ref<'a, T, R> where
R: Send,
T: Send,
R: Send,
T: Send,
impl<'a, T, R> Sync for Ref<'a, T, R> where
R: Sync,
T: Sync,
R: Sync,
T: Sync,
impl<'a, T, R> Unpin for Ref<'a, T, R> where
R: Unpin,
T: Unpin,
R: Unpin,
T: Unpin,
impl<'a, T, R> UnwindSafe for Ref<'a, T, R> where
R: UnwindSafe,
T: UnwindSafe,
R: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<U, T> AsUniform<dyn Deref<Target = [[f32; 3]; 3]> + 'static> for U where
T: AsUniform<[[f32; 3]; 3]>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = [[f32; 3]; 3]> + 'static> for U where
T: AsUniform<[[f32; 3]; 3]>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = [[f32; 4]; 4]> + 'static> for U where
T: AsUniform<[[f32; 4]; 4]>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = [[f32; 4]; 4]> + 'static> for U where
T: AsUniform<[[f32; 4]; 4]>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = [f32; 2]> + 'static> for U where
T: AsUniform<[f32; 2]>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = [f32; 2]> + 'static> for U where
T: AsUniform<[f32; 2]>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = [f32; 3]> + 'static> for U where
T: AsUniform<[f32; 3]>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = [f32; 3]> + 'static> for U where
T: AsUniform<[f32; 3]>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = [f32; 4]> + 'static> for U where
T: AsUniform<dyn AsRef<[f32; 4]> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = [f32; 4]> + 'static> for U where
T: AsUniform<dyn AsRef<[f32; 4]> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = [i32; 2]> + 'static> for U where
T: AsUniform<[i32; 2]>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = [i32; 2]> + 'static> for U where
T: AsUniform<[i32; 2]>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = [i32; 3]> + 'static> for U where
T: AsUniform<[i32; 3]>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = [i32; 3]> + 'static> for U where
T: AsUniform<[i32; 3]>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = [i32; 4]> + 'static> for U where
T: AsUniform<dyn AsRef<[i32; 4]> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = [i32; 4]> + 'static> for U where
T: AsUniform<dyn AsRef<[i32; 4]> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = [u32; 2]> + 'static> for U where
T: AsUniform<[u32; 2]>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = [u32; 2]> + 'static> for U where
T: AsUniform<[u32; 2]>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = [u32; 3]> + 'static> for U where
T: AsUniform<[u32; 3]>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = [u32; 3]> + 'static> for U where
T: AsUniform<[u32; 3]>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = [u32; 4]> + 'static> for U where
T: AsUniform<dyn AsRef<[u32; 4]> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = [u32; 4]> + 'static> for U where
T: AsUniform<dyn AsRef<[u32; 4]> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[[f32; 3]; 3]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[[f32; 3]; 3]> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[[f32; 3]; 3]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[[f32; 3]; 3]> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[[f32; 4]; 4]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[[f32; 4]; 4]> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[[f32; 4]; 4]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[[f32; 4]; 4]> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[f32; 2]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[f32; 2]> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[f32; 2]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[f32; 2]> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[f32; 3]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[f32; 3]> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[f32; 3]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[f32; 3]> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[i32; 2]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[i32; 2]> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[i32; 2]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[i32; 2]> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[i32; 3]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[i32; 3]> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[i32; 3]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[i32; 3]> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[u32; 2]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[u32; 2]> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[u32; 2]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[u32; 2]> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[u32; 3]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[u32; 3]> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<[u32; 3]> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<[u32; 3]> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<f32> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<f32> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<f32> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<f32> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<i32> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<i32> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<i32> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<i32> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<u32> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<u32> + 'static>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = dyn AsRef<u32> + 'static> + 'static> for U where
T: AsUniform<dyn AsRef<u32> + 'static>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = i32> + 'static> for U where
T: AsUniform<i32>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = i32> + 'static> for U where
T: AsUniform<i32>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<U, T> AsUniform<dyn Deref<Target = u32> + 'static> for U where
T: AsUniform<u32>,
U: Deref<Target = T>,
[src]
impl<U, T> AsUniform<dyn Deref<Target = u32> + 'static> for U where
T: AsUniform<u32>,
U: Deref<Target = T>,
[src]pub fn as_uniform(&self) -> UniformValue
[src]
impl<T> DowncastSync for T where
T: Any + Send + Sync,
[src]
impl<T> DowncastSync for T where
T: Any + Send + Sync,
[src]impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]pub fn to_subset(&self) -> Option<SS>
[src]
pub fn is_in_subset(&self) -> bool
[src]
pub fn to_subset_unchecked(&self) -> SS
[src]
pub fn from_subset(element: &SS) -> SP
[src]
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]