Struct rin::ecs::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> Deref for Ref<'a, T, R> where
    T: NToOneComponent<'a>,
    R: UnorderedData<'a>, 
[src]

type Target = R

The resulting type after dereferencing.

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> 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>>

impl<'a, T, R> SafeIter<'a> for Ref<'a, T, R> where
    T: NToOneComponent<'a>,
    R: ReadOnlyOp<'a>, 
[src]

impl<'a, T, R> SafeStreamingIter<'a> for Ref<'a, T, R> where
    T: NToOneComponent<'a>, 
[src]

Auto Trait Implementations

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

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

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

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

impl<'a, T, R> UnwindSafe for Ref<'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]