Struct rin::ecs::operators::URef[][src]

pub struct URef<'a, T, R> where
    T: OneToOneComponent<'a>, 
{ /* fields omitted */ }

Matches a component in another entity referenced through a component that Derefs to an Entity:

Entity A                           Entity C
Component(Entity) ───────────────► AnotherCompoenent

Entity B                           Entity D
Component(Entity) ───────────────► AnotherCompoenent

Allows to create OneToOne relations between entities components.

In the following example we create 2 entities that reference their geometry from other entities.

References have to implement OneToOneComponent.

As opposed to Ref and NToOneComponent this operator returns a plain iterator for write access to the referenced component since OneToOneComponent ensures that the references are unique and so the iterator won’t ever access the same component mutably more than once.

#[derive(Debug)]
struct Vertex;
#[derive(OneToOneComponent, Debug, Hash)]
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 geometry1 = world.new_entity().add(Geometry(vec![Vertex, Vertex, Vertex])).build();
let geometry2 = world.new_entity().add(Geometry(vec![Vertex, Vertex, Vertex])).build();
let a = world.new_entity()
    .add(GeometryRef(geometry1))
    .add(Position{x: 0.0, y: 0.0})
    .build();
let b = world.new_entity()
    .add(GeometryRef(geometry2))
    .add(Position{x: 0.0, y: 0.0})
    .build();
for geometry in world.iter_for_mut::<URef<GeometryRef, Write<Geometry>>>() {

}

Trait Implementations

impl<'a, T, R> DataAccesses for URef<'a, T, R> where
    T: OneToOneComponent<'a>,
    R: DataAccesses
[src]

impl<'a, T, R> Deref for URef<'a, T, R> where
    T: OneToOneComponent<'a>,
    R: UnorderedData<'a>, 
[src]

type Target = R

The resulting type after dereferencing.

impl<'a, T, R> DerefMut for URef<'a, T, R> where
    T: OneToOneComponent<'a>,
    R: UnorderedData<'a>, 
[src]

impl<'a, T, R> FromComponent<'a, <R as UnorderedData<'a>>::ComponentsRef> for URef<'a, T, R> where
    T: OneToOneComponent<'a>,
    R: UnorderedData<'a> + FromComponent<'a, <R as UnorderedData<'a>>::ComponentsRef>, 
[src]

impl<'a, T, R> UnorderedData<'a> for URef<'a, T, R> where
    T: OneToOneComponent<'a> + Component,
    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, <URef<'a, T, R> as UnorderedData<'a>>::Storage>

type IterMut = RefIter<'a, <URef<'a, T, R> as UnorderedData<'a>>::Storage>

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, URefData, LazyIndexGuard<'a>>

impl<'a, T, R> SafeIter<'a> for URef<'a, T, R> where
    T: OneToOneComponent<'a>,
    R: SafeIter<'a>, 
[src]

impl<'a, T, R> SafeStreamingIter<'a> for URef<'a, T, R> where
    T: OneToOneComponent<'a>, 
[src]

Auto Trait Implementations

impl<'a, T, R> RefUnwindSafe for URef<'a, T, R> where
    R: RefUnwindSafe,
    T: RefUnwindSafe

impl<'a, T, R> Send for URef<'a, T, R> where
    R: Send,
    T: Send

impl<'a, T, R> Sync for URef<'a, T, R> where
    R: Sync,
    T: Sync

impl<'a, T, R> Unpin for URef<'a, T, R> where
    R: Unpin,
    T: Unpin

impl<'a, T, R> UnwindSafe for URef<'a, T, R> where
    R: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any
[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]

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; 2]> + 'static> for U where
    T: AsUniform<[f32; 2]>,
    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]

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 = [i32; 2]> + 'static> for U where
    T: AsUniform<[i32; 2]>,
    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]

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 = [u32; 2]> + 'static> for U where
    T: AsUniform<[u32; 2]>,
    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]

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 = 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; 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; 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; 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<[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; 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<[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; 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<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<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<u32> + 'static> + 'static> for U where
    T: AsUniform<dyn AsRef<u32> + 'static>,
    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]

impl<U, T> AsUniform<dyn Deref<Target = u32> + 'static> for U where
    T: AsUniform<u32>,
    U: Deref<Target = T>, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Any + Send + Sync
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<V> IntoPnt<V> for V[src]

impl<V> IntoVec<V> for V[src]

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]