Trait View

Source
pub trait View<'a>:
    Sized
    + Send
    + Sync
    + 'static {
    type Iter: Iterator + 'a;

    // Required methods
    fn fetch(
        archetype: &'a ArchetypeData,
        chunk: &'a ComponentStorage,
        chunk_index: ChunkIndex,
        set_index: SetIndex,
    ) -> Self::Iter;
    fn validate() -> bool;
    fn validate_access(access: &ComponentAccess<'_>) -> bool;
    fn reads<T: Component>() -> bool;
    fn writes<T: Component>() -> bool;
    fn requires_permissions() -> Permissions<ComponentTypeId>;
}
Expand description

A type which can fetch a strongly-typed view of the data contained within a chunk.

Required Associated Types§

Source

type Iter: Iterator + 'a

The iterator over the chunk data.

Required Methods§

Source

fn fetch( archetype: &'a ArchetypeData, chunk: &'a ComponentStorage, chunk_index: ChunkIndex, set_index: SetIndex, ) -> Self::Iter

Pulls data out of a chunk.

Source

fn validate() -> bool

Validates that the view does not break any component borrowing rules.

Source

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

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

Source

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

Determines if the view reads the specified data type.

Source

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

Determines if the view writes to the specified data type.

Source

fn requires_permissions() -> Permissions<ComponentTypeId>

Returns the set of permissions 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: ViewElement + View<'a>> View<'a> for (A,)

Source§

type Iter = Zip<(<A as View<'a>>::Iter,)>

Source§

fn fetch( archetype: &'a ArchetypeData, chunk: &'a ComponentStorage, chunk_index: ChunkIndex, set_index: SetIndex, ) -> Self::Iter

Source§

fn validate() -> bool

Source§

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

Source§

fn reads<Data: Component>() -> bool

Source§

fn writes<Data: Component>() -> bool

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

impl<'a, A: ViewElement + View<'a>, B: ViewElement + View<'a>> View<'a> for (A, B)

Source§

type Iter = Zip<(<A as View<'a>>::Iter, <B as View<'a>>::Iter)>

Source§

fn fetch( archetype: &'a ArchetypeData, chunk: &'a ComponentStorage, chunk_index: ChunkIndex, set_index: SetIndex, ) -> Self::Iter

Source§

fn validate() -> bool

Source§

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

Source§

fn reads<Data: Component>() -> bool

Source§

fn writes<Data: Component>() -> bool

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

impl<'a, A: ViewElement + View<'a>, B: ViewElement + View<'a>, C: ViewElement + View<'a>> View<'a> for (A, B, C)

Source§

type Iter = Zip<(<A as View<'a>>::Iter, <B as View<'a>>::Iter, <C as View<'a>>::Iter)>

Source§

fn fetch( archetype: &'a ArchetypeData, chunk: &'a ComponentStorage, chunk_index: ChunkIndex, set_index: SetIndex, ) -> Self::Iter

Source§

fn validate() -> bool

Source§

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

Source§

fn reads<Data: Component>() -> bool

Source§

fn writes<Data: Component>() -> bool

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

impl<'a, A: ViewElement + View<'a>, B: ViewElement + View<'a>, C: ViewElement + View<'a>, D: ViewElement + View<'a>> View<'a> for (A, B, C, D)

Source§

type Iter = Zip<(<A as View<'a>>::Iter, <B as View<'a>>::Iter, <C as View<'a>>::Iter, <D as View<'a>>::Iter)>

Source§

fn fetch( archetype: &'a ArchetypeData, chunk: &'a ComponentStorage, chunk_index: ChunkIndex, set_index: SetIndex, ) -> Self::Iter

Source§

fn validate() -> bool

Source§

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

Source§

fn reads<Data: Component>() -> bool

Source§

fn writes<Data: Component>() -> bool

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

impl<'a, A: ViewElement + View<'a>, B: ViewElement + View<'a>, C: ViewElement + View<'a>, D: ViewElement + View<'a>, E: ViewElement + View<'a>> View<'a> for (A, B, C, D, E)

Source§

type Iter = 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)>

Source§

fn fetch( archetype: &'a ArchetypeData, chunk: &'a ComponentStorage, chunk_index: ChunkIndex, set_index: SetIndex, ) -> Self::Iter

Source§

fn validate() -> bool

Source§

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

Source§

fn reads<Data: Component>() -> bool

Source§

fn writes<Data: Component>() -> bool

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

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

Source§

type Iter = 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)>

Source§

fn fetch( archetype: &'a ArchetypeData, chunk: &'a ComponentStorage, chunk_index: ChunkIndex, set_index: SetIndex, ) -> Self::Iter

Source§

fn validate() -> bool

Source§

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

Source§

fn reads<Data: Component>() -> bool

Source§

fn writes<Data: Component>() -> bool

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

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

Source§

type Iter = 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)>

Source§

fn fetch( archetype: &'a ArchetypeData, chunk: &'a ComponentStorage, chunk_index: ChunkIndex, set_index: SetIndex, ) -> Self::Iter

Source§

fn validate() -> bool

Source§

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

Source§

fn reads<Data: Component>() -> bool

Source§

fn writes<Data: Component>() -> bool

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

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

Source§

type Iter = 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)>

Source§

fn fetch( archetype: &'a ArchetypeData, chunk: &'a ComponentStorage, chunk_index: ChunkIndex, set_index: SetIndex, ) -> Self::Iter

Source§

fn validate() -> bool

Source§

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

Source§

fn reads<Data: Component>() -> bool

Source§

fn writes<Data: Component>() -> bool

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

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

Source§

type Iter = 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, <I as View<'a>>::Iter)>

Source§

fn fetch( archetype: &'a ArchetypeData, chunk: &'a ComponentStorage, chunk_index: ChunkIndex, set_index: SetIndex, ) -> Self::Iter

Source§

fn validate() -> bool

Source§

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

Source§

fn reads<Data: Component>() -> bool

Source§

fn writes<Data: Component>() -> bool

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

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

Source§

type Iter = 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, <I as View<'a>>::Iter, <J as View<'a>>::Iter)>

Source§

fn fetch( archetype: &'a ArchetypeData, chunk: &'a ComponentStorage, chunk_index: ChunkIndex, set_index: SetIndex, ) -> Self::Iter

Source§

fn validate() -> bool

Source§

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

Source§

fn reads<Data: Component>() -> bool

Source§

fn writes<Data: Component>() -> bool

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

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

Source§

type Iter = 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, <I as View<'a>>::Iter, <J as View<'a>>::Iter, <K as View<'a>>::Iter)>

Source§

fn fetch( archetype: &'a ArchetypeData, chunk: &'a ComponentStorage, chunk_index: ChunkIndex, set_index: SetIndex, ) -> Self::Iter

Source§

fn validate() -> bool

Source§

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

Source§

fn reads<Data: Component>() -> bool

Source§

fn writes<Data: Component>() -> bool

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Source§

impl<'a, A: ViewElement + View<'a>, B: ViewElement + View<'a>, C: ViewElement + View<'a>, D: ViewElement + View<'a>, E: ViewElement + View<'a>, F: ViewElement + View<'a>, G: ViewElement + View<'a>, H: ViewElement + View<'a>, I: ViewElement + View<'a>, J: ViewElement + View<'a>, K: ViewElement + View<'a>, L: ViewElement + View<'a>> View<'a> for (A, B, C, D, E, F, G, H, I, J, K, L)

Source§

type Iter = 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, <I as View<'a>>::Iter, <J as View<'a>>::Iter, <K as View<'a>>::Iter, <L as View<'a>>::Iter)>

Source§

fn fetch( archetype: &'a ArchetypeData, chunk: &'a ComponentStorage, chunk_index: ChunkIndex, set_index: SetIndex, ) -> Self::Iter

Source§

fn validate() -> bool

Source§

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

Source§

fn reads<Data: Component>() -> bool

Source§

fn writes<Data: Component>() -> bool

Source§

fn requires_permissions() -> Permissions<ComponentTypeId>

Implementors§

Source§

impl<'a, T: Component> View<'a> for Read<T>

Source§

type Iter = RefIter<'a, T, Iter<'a, T>>

Source§

impl<'a, T: Component> View<'a> for TryRead<T>

Source§

type Iter = TryRefIter<'a, T, Iter<'a, T>>

Source§

impl<'a, T: Component> View<'a> for TryWrite<T>

Source§

type Iter = TryRefIterMut<'a, T, IterMut<'a, T>>

Source§

impl<'a, T: Component> View<'a> for Write<T>

Source§

type Iter = RefIterMut<'a, T, IterMut<'a, T>>

Source§

impl<'a, T: Tag> View<'a> for Tagged<T>