pub trait Fetch<'world, 'state> {
type Item;
type State: FetchState;
const IS_DENSE: bool;
unsafe fn init(
world: &World,
state: &Self::State,
last_change_tick: u32,
change_tick: u32
) -> Self;
unsafe fn set_archetype(
&mut self,
state: &Self::State,
archetype: &Archetype,
tables: &Tables
);
unsafe fn set_table(&mut self, state: &Self::State, table: &Table);
unsafe fn archetype_fetch(&mut self, archetype_index: usize) -> Self::Item;
unsafe fn table_fetch(&mut self, table_row: usize) -> Self::Item;
}
Associated Types
type Item
type State: FetchState
Associated Constants
Returns true if (and only if) every table of every archetype matched by this Fetch contains
all of the matched components. This is used to select a more efficient “table iterator”
for “dense” queries. If this returns true, Fetch::set_table
and Fetch::table_fetch
will be called for iterators. If this returns false, Fetch::set_archetype
and
Fetch::archetype_fetch
will be called for iterators.
Required methods
Creates a new instance of this fetch.
Safety
state
must have been initialized (via FetchState::init
) using the same world
passed
in to this function.
unsafe fn set_archetype(
&mut self,
state: &Self::State,
archetype: &Archetype,
tables: &Tables
)
unsafe fn set_archetype(
&mut self,
state: &Self::State,
archetype: &Archetype,
tables: &Tables
)
Adjusts internal state to account for the next Archetype
. This will always be called on
archetypes that match this Fetch
.
Safety
archetype
and tables
must be from the World
Fetch::init
was called on. state
must be the Self::State
this was initialized with.
Adjusts internal state to account for the next Table
. This will always be called on tables
that match this Fetch
.
Safety
table
must be from the World
Fetch::init
was called on. state
must be the
Self::State
this was initialized with.
unsafe fn archetype_fetch(&mut self, archetype_index: usize) -> Self::Item
unsafe fn archetype_fetch(&mut self, archetype_index: usize) -> Self::Item
Fetch Self::Item
for the given archetype_index
in the current Archetype
. This must
always be called after Fetch::set_archetype
with an archetype_index
in the range of
the current Archetype
Safety
Must always be called after Fetch::set_archetype
. archetype_index
must be in the range
of the current archetype
unsafe fn table_fetch(&mut self, table_row: usize) -> Self::Item
unsafe fn table_fetch(&mut self, table_row: usize) -> Self::Item
Fetch Self::Item
for the given table_row
in the current Table
. This must always be
called after Fetch::set_table
with a table_row
in the range of the current Table
Safety
Must always be called after Fetch::set_table
. table_row
must be in the range of the
current table