Skip to main content

PlanBuilder

Struct PlanBuilder 

Source
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>

Source

pub(crate) fn new( archetype: &'w Archetype, asked: Vec<(TypeId, &'static str, Mode)>, ) -> Self

Source

pub(crate) fn asks(&self) -> &[(TypeId, &'static str, Mode)]

The asks recorded so far, which is what the holder claims.

Source

pub(crate) fn into_asks(self) -> Vec<(TypeId, &'static str, Mode)>

Recover the buffer, so the next archetype reuses it instead of allocating.

Source

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.

Source

pub fn write<T: 'static>(&mut self) -> Option<ColMut<'w, T>>

The archetype’s column of T, exclusive. None when it carries no T.

Source

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.

Source

pub fn entities(&self) -> &'w [Entity]

The entities of the archetype, one per row.

Source

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.

Auto Trait Implementations§

§

impl<'w> !RefUnwindSafe for PlanBuilder<'w>

§

impl<'w> !Send for PlanBuilder<'w>

§

impl<'w> !Sync for PlanBuilder<'w>

§

impl<'w> !UnwindSafe for PlanBuilder<'w>

§

impl<'w> Forget for PlanBuilder<'w>

§

impl<'w> Freeze for PlanBuilder<'w>

§

impl<'w> Unpin for PlanBuilder<'w>

§

impl<'w> UnsafeUnpin for PlanBuilder<'w>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Component for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more