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§
Sourcetype Fetch: Fetch<Item = Self::Element> + IntoIndexableIter + 'data
type Fetch: Fetch<Item = Self::Element> + IntoIndexableIter + 'data
The fetch type yielded for each archetype.
Sourcetype Iter: Iterator<Item = Option<Self::Fetch>> + 'data
type Iter: Iterator<Item = Option<Self::Fetch>> + 'data
The iterator type which pulls entity data out of a world.
Sourcetype Read: AsRef<[ComponentTypeId]>
type Read: AsRef<[ComponentTypeId]>
Contains the type IDs read by the view.
Sourcetype Write: AsRef<[ComponentTypeId]>
type Write: AsRef<[ComponentTypeId]>
Contains the type IDs written by the view.
Required Methods§
Sourceunsafe fn fetch(
components: &'data Components,
archetypes: &'data [Archetype],
query: QueryResult<'data>,
) -> Self::Iter
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.
Sourcefn validate_access(access: &ComponentAccess<'_>) -> bool
fn validate_access(access: &ComponentAccess<'_>) -> bool
Returns true
if the given component access includes all permissions required by the view.
Sourcefn reads_types() -> Self::Read
fn reads_types() -> Self::Read
Returns the component types read by the view.
Sourcefn writes_types() -> Self::Write
fn writes_types() -> Self::Write
Returns the component types written to by the view.
Sourcefn reads<T>() -> boolwhere
T: Component,
fn reads<T>() -> boolwhere
T: Component,
Returns true
if the view reads the specified data type.
Sourcefn writes<T>() -> boolwhere
T: Component,
fn writes<T>() -> boolwhere
T: Component,
Returns true
if the view writes to the specified data type.
Sourcefn requires_permissions() -> Permissions<ComponentTypeId>
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.