Trait View

Source
pub trait View<'data>: Sized + DefaultFilter {
    type Element: Send + Sync + 'data;
    type Fetch: Fetch<Item = Self::Element> + IntoIndexableIter + 'data;
    type Iter: Iterator<Item = Option<Self::Fetch>> + 'data;
    type Read: AsRef<[ComponentTypeId]>;
    type Write: AsRef<[ComponentTypeId]>;

    // Required methods
    unsafe fn fetch(
        components: &'data Components,
        archetypes: &'data [Archetype],
        query: QueryResult<'data>,
    ) -> Self::Iter;
    fn validate();
    fn validate_access(access: &ComponentAccess<'_>) -> bool;
    fn reads_types() -> Self::Read;
    fn writes_types() -> Self::Write;
    fn reads<T>() -> bool
       where T: Component;
    fn writes<T>() -> bool
       where T: Component;
    fn requires_permissions() -> Permissions<ComponentTypeId>;
}
Expand description

A type which can pull entity data out of a world.

Required Associated Types§

Source

type Element: Send + Sync + 'data

The type of component references returned.

Source

type Fetch: Fetch<Item = Self::Element> + IntoIndexableIter + 'data

The fetch type yielded for each archetype.

Source

type Iter: Iterator<Item = Option<Self::Fetch>> + 'data

The iterator type which pulls entity data out of a world.

Source

type Read: AsRef<[ComponentTypeId]>

Contains the type IDs read by the view.

Source

type Write: AsRef<[ComponentTypeId]>

Contains the type IDs written by the view.

Required Methods§

Source

unsafe fn fetch( components: &'data Components, archetypes: &'data [Archetype], query: QueryResult<'data>, ) -> Self::Iter

Creates an iterator which will yield slices of entity data for each archetype.

§Safety

This method may return mutable references to entity data via shared world references. The caller must ensure that no two view iterators are alive at the same time which access any components in a manner which may cause mutable aliasing.

Source

fn validate()

Determines if this view type is valid. Panics if checks fail.

Source

fn validate_access(access: &ComponentAccess<'_>) -> bool

Returns true if the given component access includes all permissions required by the view.

Source

fn reads_types() -> Self::Read

Returns the component types read by the view.

Source

fn writes_types() -> Self::Write

Returns the component types written to by the view.

Source

fn reads<T>() -> bool
where T: Component,

Returns true if the view reads the specified data type.

Source

fn writes<T>() -> bool
where T: Component,

Returns true if the view writes to the specified data type.

Source

fn requires_permissions() -> Permissions<ComponentTypeId>

Returns a permissions struct declaring the component accesses required by the view.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, A, B, C, D, E, F, G, H> View<'a> for (A, B, C, D, E, F, G, H)
where A: View<'a> + 'a, B: View<'a> + 'a, C: View<'a> + 'a, D: View<'a> + 'a, E: View<'a> + 'a, F: View<'a> + 'a, G: View<'a> + 'a, H: View<'a> + 'a,

Source§

type Element = <<(A, B, C, D, E, F, G, H) as View<'a>>::Fetch as IntoIndexableIter>::Item

Source§

type Fetch = MultiFetch<'a, (<A as View<'a>>::Fetch, <B as View<'a>>::Fetch, <C as View<'a>>::Fetch, <D as View<'a>>::Fetch, <E as View<'a>>::Fetch, <F as View<'a>>::Fetch, <G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>

Source§

type Iter = MapInto<Zip<(<A as View<'a>>::Iter, <B as View<'a>>::Iter, <C as View<'a>>::Iter, <D as View<'a>>::Iter, <E as View<'a>>::Iter, <F as View<'a>>::Iter, <G as View<'a>>::Iter, <H as View<'a>>::Iter)>, Option<MultiFetch<'a, (<A as View<'a>>::Fetch, <B as View<'a>>::Fetch, <C as View<'a>>::Fetch, <D as View<'a>>::Fetch, <E as View<'a>>::Fetch, <F as View<'a>>::Fetch, <G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>>>

Source§

type Read = Vec<ComponentTypeId>

Source§

type Write = Vec<ComponentTypeId>

Source§

unsafe fn fetch( components: &'a Components, archetypes: &'a [Archetype], query: QueryResult<'a>, ) -> <(A, B, C, D, E, F, G, H) as View<'a>>::Iter

Source§

fn validate()

Source§

fn validate_access(access: &ComponentAccess<'_>) -> bool

Source§

fn reads_types() -> <(A, B, C, D, E, F, G, H) as View<'a>>::Read

Source§

fn writes_types() -> <(A, B, C, D, E, F, G, H) as View<'a>>::Write

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

fn reads<Comp>() -> bool
where Comp: Component,

Source§

fn writes<Comp>() -> bool
where Comp: Component,

Source§

impl<'a, B, C, D, E, F, G, H> View<'a> for (B, C, D, E, F, G, H)
where B: View<'a> + 'a, C: View<'a> + 'a, D: View<'a> + 'a, E: View<'a> + 'a, F: View<'a> + 'a, G: View<'a> + 'a, H: View<'a> + 'a,

Source§

type Element = <<(B, C, D, E, F, G, H) as View<'a>>::Fetch as IntoIndexableIter>::Item

Source§

type Fetch = MultiFetch<'a, (<B as View<'a>>::Fetch, <C as View<'a>>::Fetch, <D as View<'a>>::Fetch, <E as View<'a>>::Fetch, <F as View<'a>>::Fetch, <G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>

Source§

type Iter = MapInto<Zip<(<B as View<'a>>::Iter, <C as View<'a>>::Iter, <D as View<'a>>::Iter, <E as View<'a>>::Iter, <F as View<'a>>::Iter, <G as View<'a>>::Iter, <H as View<'a>>::Iter)>, Option<MultiFetch<'a, (<B as View<'a>>::Fetch, <C as View<'a>>::Fetch, <D as View<'a>>::Fetch, <E as View<'a>>::Fetch, <F as View<'a>>::Fetch, <G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>>>

Source§

type Read = Vec<ComponentTypeId>

Source§

type Write = Vec<ComponentTypeId>

Source§

unsafe fn fetch( components: &'a Components, archetypes: &'a [Archetype], query: QueryResult<'a>, ) -> <(B, C, D, E, F, G, H) as View<'a>>::Iter

Source§

fn validate()

Source§

fn validate_access(access: &ComponentAccess<'_>) -> bool

Source§

fn reads_types() -> <(B, C, D, E, F, G, H) as View<'a>>::Read

Source§

fn writes_types() -> <(B, C, D, E, F, G, H) as View<'a>>::Write

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

fn reads<Comp>() -> bool
where Comp: Component,

Source§

fn writes<Comp>() -> bool
where Comp: Component,

Source§

impl<'a, C, D, E, F, G, H> View<'a> for (C, D, E, F, G, H)
where C: View<'a> + 'a, D: View<'a> + 'a, E: View<'a> + 'a, F: View<'a> + 'a, G: View<'a> + 'a, H: View<'a> + 'a,

Source§

type Element = <<(C, D, E, F, G, H) as View<'a>>::Fetch as IntoIndexableIter>::Item

Source§

type Fetch = MultiFetch<'a, (<C as View<'a>>::Fetch, <D as View<'a>>::Fetch, <E as View<'a>>::Fetch, <F as View<'a>>::Fetch, <G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>

Source§

type Iter = MapInto<Zip<(<C as View<'a>>::Iter, <D as View<'a>>::Iter, <E as View<'a>>::Iter, <F as View<'a>>::Iter, <G as View<'a>>::Iter, <H as View<'a>>::Iter)>, Option<MultiFetch<'a, (<C as View<'a>>::Fetch, <D as View<'a>>::Fetch, <E as View<'a>>::Fetch, <F as View<'a>>::Fetch, <G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>>>

Source§

type Read = Vec<ComponentTypeId>

Source§

type Write = Vec<ComponentTypeId>

Source§

unsafe fn fetch( components: &'a Components, archetypes: &'a [Archetype], query: QueryResult<'a>, ) -> <(C, D, E, F, G, H) as View<'a>>::Iter

Source§

fn validate()

Source§

fn validate_access(access: &ComponentAccess<'_>) -> bool

Source§

fn reads_types() -> <(C, D, E, F, G, H) as View<'a>>::Read

Source§

fn writes_types() -> <(C, D, E, F, G, H) as View<'a>>::Write

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

fn reads<Comp>() -> bool
where Comp: Component,

Source§

fn writes<Comp>() -> bool
where Comp: Component,

Source§

impl<'a, D, E, F, G, H> View<'a> for (D, E, F, G, H)
where D: View<'a> + 'a, E: View<'a> + 'a, F: View<'a> + 'a, G: View<'a> + 'a, H: View<'a> + 'a,

Source§

type Element = <<(D, E, F, G, H) as View<'a>>::Fetch as IntoIndexableIter>::Item

Source§

type Fetch = MultiFetch<'a, (<D as View<'a>>::Fetch, <E as View<'a>>::Fetch, <F as View<'a>>::Fetch, <G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>

Source§

type Iter = MapInto<Zip<(<D as View<'a>>::Iter, <E as View<'a>>::Iter, <F as View<'a>>::Iter, <G as View<'a>>::Iter, <H as View<'a>>::Iter)>, Option<MultiFetch<'a, (<D as View<'a>>::Fetch, <E as View<'a>>::Fetch, <F as View<'a>>::Fetch, <G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>>>

Source§

type Read = Vec<ComponentTypeId>

Source§

type Write = Vec<ComponentTypeId>

Source§

unsafe fn fetch( components: &'a Components, archetypes: &'a [Archetype], query: QueryResult<'a>, ) -> <(D, E, F, G, H) as View<'a>>::Iter

Source§

fn validate()

Source§

fn validate_access(access: &ComponentAccess<'_>) -> bool

Source§

fn reads_types() -> <(D, E, F, G, H) as View<'a>>::Read

Source§

fn writes_types() -> <(D, E, F, G, H) as View<'a>>::Write

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

fn reads<Comp>() -> bool
where Comp: Component,

Source§

fn writes<Comp>() -> bool
where Comp: Component,

Source§

impl<'a, E, F, G, H> View<'a> for (E, F, G, H)
where E: View<'a> + 'a, F: View<'a> + 'a, G: View<'a> + 'a, H: View<'a> + 'a,

Source§

type Element = <<(E, F, G, H) as View<'a>>::Fetch as IntoIndexableIter>::Item

Source§

type Fetch = MultiFetch<'a, (<E as View<'a>>::Fetch, <F as View<'a>>::Fetch, <G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>

Source§

type Iter = MapInto<Zip<(<E as View<'a>>::Iter, <F as View<'a>>::Iter, <G as View<'a>>::Iter, <H as View<'a>>::Iter)>, Option<MultiFetch<'a, (<E as View<'a>>::Fetch, <F as View<'a>>::Fetch, <G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>>>

Source§

type Read = Vec<ComponentTypeId>

Source§

type Write = Vec<ComponentTypeId>

Source§

unsafe fn fetch( components: &'a Components, archetypes: &'a [Archetype], query: QueryResult<'a>, ) -> <(E, F, G, H) as View<'a>>::Iter

Source§

fn validate()

Source§

fn validate_access(access: &ComponentAccess<'_>) -> bool

Source§

fn reads_types() -> <(E, F, G, H) as View<'a>>::Read

Source§

fn writes_types() -> <(E, F, G, H) as View<'a>>::Write

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

fn reads<Comp>() -> bool
where Comp: Component,

Source§

fn writes<Comp>() -> bool
where Comp: Component,

Source§

impl<'a, F, G, H> View<'a> for (F, G, H)
where F: View<'a> + 'a, G: View<'a> + 'a, H: View<'a> + 'a,

Source§

type Element = <<(F, G, H) as View<'a>>::Fetch as IntoIndexableIter>::Item

Source§

type Fetch = MultiFetch<'a, (<F as View<'a>>::Fetch, <G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>

Source§

type Iter = MapInto<Zip<(<F as View<'a>>::Iter, <G as View<'a>>::Iter, <H as View<'a>>::Iter)>, Option<MultiFetch<'a, (<F as View<'a>>::Fetch, <G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>>>

Source§

type Read = Vec<ComponentTypeId>

Source§

type Write = Vec<ComponentTypeId>

Source§

unsafe fn fetch( components: &'a Components, archetypes: &'a [Archetype], query: QueryResult<'a>, ) -> <(F, G, H) as View<'a>>::Iter

Source§

fn validate()

Source§

fn validate_access(access: &ComponentAccess<'_>) -> bool

Source§

fn reads_types() -> <(F, G, H) as View<'a>>::Read

Source§

fn writes_types() -> <(F, G, H) as View<'a>>::Write

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

fn reads<Comp>() -> bool
where Comp: Component,

Source§

fn writes<Comp>() -> bool
where Comp: Component,

Source§

impl<'a, G, H> View<'a> for (G, H)
where G: View<'a> + 'a, H: View<'a> + 'a,

Source§

type Element = <<(G, H) as View<'a>>::Fetch as IntoIndexableIter>::Item

Source§

type Fetch = MultiFetch<'a, (<G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>

Source§

type Iter = MapInto<Zip<(<G as View<'a>>::Iter, <H as View<'a>>::Iter)>, Option<MultiFetch<'a, (<G as View<'a>>::Fetch, <H as View<'a>>::Fetch)>>>

Source§

type Read = Vec<ComponentTypeId>

Source§

type Write = Vec<ComponentTypeId>

Source§

unsafe fn fetch( components: &'a Components, archetypes: &'a [Archetype], query: QueryResult<'a>, ) -> <(G, H) as View<'a>>::Iter

Source§

fn validate()

Source§

fn validate_access(access: &ComponentAccess<'_>) -> bool

Source§

fn reads_types() -> <(G, H) as View<'a>>::Read

Source§

fn writes_types() -> <(G, H) as View<'a>>::Write

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

fn reads<Comp>() -> bool
where Comp: Component,

Source§

fn writes<Comp>() -> bool
where Comp: Component,

Source§

impl<'a, H> View<'a> for (H,)
where H: View<'a> + 'a,

Source§

type Element = <<(H,) as View<'a>>::Fetch as IntoIndexableIter>::Item

Source§

type Fetch = MultiFetch<'a, (<H as View<'a>>::Fetch,)>

Source§

type Iter = MapInto<Zip<(<H as View<'a>>::Iter,)>, Option<MultiFetch<'a, (<H as View<'a>>::Fetch,)>>>

Source§

type Read = Vec<ComponentTypeId>

Source§

type Write = Vec<ComponentTypeId>

Source§

unsafe fn fetch( components: &'a Components, archetypes: &'a [Archetype], query: QueryResult<'a>, ) -> <(H,) as View<'a>>::Iter

Source§

fn validate()

Source§

fn validate_access(access: &ComponentAccess<'_>) -> bool

Source§

fn reads_types() -> <(H,) as View<'a>>::Read

Source§

fn writes_types() -> <(H,) as View<'a>>::Write

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

fn reads<Comp>() -> bool
where Comp: Component,

Source§

fn writes<Comp>() -> bool
where Comp: Component,

Implementors§

Source§

impl<'data> View<'data> for Entity

Source§

type Element = <<Entity as View<'data>>::Fetch as IntoIndexableIter>::Item

Source§

type Fetch = EntityFetch<'data>

Source§

type Iter = Iter<'data>

Source§

type Read = [ComponentTypeId; 0]

Source§

type Write = [ComponentTypeId; 0]

Source§

impl<'data, T> View<'data> for Read<T>
where T: Component,

Source§

type Element = <<Read<T> as View<'data>>::Fetch as IntoIndexableIter>::Item

Source§

type Fetch = ReadFetch<'data, T>

Source§

type Iter = ReadIter<'data, T>

Source§

type Read = [ComponentTypeId; 1]

Source§

type Write = [ComponentTypeId; 0]

Source§

impl<'data, T> View<'data> for TryRead<T>
where T: Component,

Source§

type Element = <<TryRead<T> as View<'data>>::Fetch as IntoIndexableIter>::Item

Source§

type Fetch = Slice<'data, T>

Source§

type Iter = TryReadIter<'data, T>

Source§

type Read = [ComponentTypeId; 1]

Source§

type Write = [ComponentTypeId; 0]

Source§

impl<'data, T> View<'data> for TryWrite<T>
where T: Component,

Source§

type Element = <<TryWrite<T> as View<'data>>::Fetch as IntoIndexableIter>::Item

Source§

type Fetch = Slice<'data, T>

Source§

type Iter = TryWriteIter<'data, T>

Source§

type Read = [ComponentTypeId; 1]

Source§

type Write = [ComponentTypeId; 1]

Source§

impl<'data, T> View<'data> for Write<T>
where T: Component,

Source§

type Element = <<Write<T> as View<'data>>::Fetch as IntoIndexableIter>::Item

Source§

type Fetch = WriteFetch<'data, T>

Source§

type Iter = WriteIter<'data, T>

Source§

type Read = [ComponentTypeId; 1]

Source§

type Write = [ComponentTypeId; 1]