pub struct PlanBuilder<'w> {
archetype: &'w Archetype,
asked: Vec<(TypeId, &'static str, Mode)>,
marker: PhantomData<&'w ()>,
}Expand description
What one archetype offers, and what a query asks of it while resolving its plan.
This is the only way a query reaches a column, so asking for one is the
claim: there is no separate list of reached components that could disagree
with what Query::read actually reads. A duplicate ask that would need
two modes for one type is refused here, before anything is handed out.
Fields§
§archetype: &'w Archetype§asked: Vec<(TypeId, &'static str, Mode)>§marker: PhantomData<&'w ()>Implementations§
Source§impl<'w> PlanBuilder<'w>
impl<'w> PlanBuilder<'w>
pub(crate) fn new( archetype: &'w Archetype, asked: Vec<(TypeId, &'static str, Mode)>, ) -> Self
Sourcepub(crate) fn asks(&self) -> &[(TypeId, &'static str, Mode)]
pub(crate) fn asks(&self) -> &[(TypeId, &'static str, Mode)]
The asks recorded so far, which is what the holder claims.
Sourcepub(crate) fn into_asks(self) -> Vec<(TypeId, &'static str, Mode)>
pub(crate) fn into_asks(self) -> Vec<(TypeId, &'static str, Mode)>
Recover the buffer, so the next archetype reuses it instead of allocating.
Sourcepub fn read<T: 'static>(&mut self) -> Option<Col<'w, T>>
pub fn read<T: 'static>(&mut self) -> Option<Col<'w, T>>
The archetype’s column of T, shared. None when it carries no
T, which is what makes the query skip it.
Sourcepub fn write<T: 'static>(&mut self) -> Option<ColMut<'w, T>>
pub fn write<T: 'static>(&mut self) -> Option<ColMut<'w, T>>
The archetype’s column of T, exclusive. None when it carries no
T.
Sourcepub fn has<T: 'static>(&self) -> bool
pub fn has<T: 'static>(&self) -> bool
Whether the archetype carries T.
Claims nothing: a yes/no answer cannot alias anything, which is what
keeps (&mut T, Has<T>) legal.
Sourcefn ask<T: 'static>(&mut self, mode: Mode) -> Option<&'w [UnsafeCell<T>]>
fn ask<T: 'static>(&mut self, mode: Mode) -> Option<&'w [UnsafeCell<T>]>
Record that the query reaches T in mode, and resolve its column.
Panics when the same query asks for T twice with at least one of the
asks exclusive: the two would hand out references that cannot coexist.