pub struct SubWorldRaw<A, T> { /* private fields */ }
Expand description

Represents a borrow of the world which can only access a subset of components (unless AllAccess is used).

This type allows for any reference kind, such as &World, AtomicRef, Ref, etc.

Type alises are provided for the most common usages, with SubWorld being the one used by Schedule.

Implementations§

source§

impl<A, T> SubWorldRaw<A, T>

source

pub fn new(world: A) -> Self

Splits the world into a subworld. No borrow checking is performed so may fail during query unless guarded otherwise.

source§

impl<A, T: ComponentBorrow> SubWorldRaw<A, T>

source

pub fn has<U: IntoAccess>(&self) -> bool

Returns true if the subworld can access the borrow of T

source

pub fn has_all<U: Subset>(&self) -> bool

Returns true if the world satisfies the whole query

source§

impl<'w, A: 'w + Deref<Target = World>, T: ComponentBorrow> SubWorldRaw<A, T>

source

pub fn query<Q: Query + Subset>(&self) -> QueryBorrow<'_, Q>

Query the subworld.

Panics

Panics if the query items are not a compatible subset of the subworld.

source

pub fn query_one<Q: Query + Subset>( &'w self, entity: Entity ) -> Result<QueryOne<'w, Q>>

Query the subworld for a single entity. Wraps the hecs::NoSuchEntity error and provides the entity id

source

pub fn get<C: Component>(&self, entity: Entity) -> Result<Ref<'_, C>>

Get a single component from the world.

Wraps the hecs::NoSuchEntity error and provides the entity id

source

pub fn get_mut<C: Component>(&self, entity: Entity) -> Result<RefMut<'_, C>>

Get a single component from the world.

Wraps the hecs::NoSuchEntity error and provides the entity id

source

pub fn reserve_entities(&self, count: u32) -> impl Iterator<Item = Entity> + '_

Reserve multiple entities concurrently

source

pub fn query_par<Q: Query + Subset>(&self) -> QueryBorrow<'_, Q>

Query the subworld.

Panics

Panics if the query items are not a compatible subset of the subworld.

source§

impl<A: Deref<Target = World>, T: Query> SubWorldRaw<A, T>

source

pub fn native_query(&self) -> QueryBorrow<'_, T>

Query the full access of the subworld. Does not fail as access is guaranteed

source§

impl<A: ExternalClone, T: ComponentBorrow> SubWorldRaw<A, T>

source

pub fn split<U: ComponentBorrow + Subset>(&self) -> Result<SubWorldRaw<A, U>>

Splits the subworld further into a compatible subworld. Fails if not compatible

Trait Implementations§

source§

impl<A, T: ComponentBorrow + Query> ComponentBorrow for SubWorldRaw<A, T>

source§

fn borrows() -> Borrows

Returns a list of all component accesses
source§

fn has<U: IntoAccess>() -> bool

Returns true if U exists in Self
source§

fn has_dynamic(id: TypeId, exclusive: bool) -> bool

Returns true if id exists in Self
source§

impl<'a, T> From<&'a Context<'a>> for SubWorldRaw<AtomicRef<'a, World>, T>

source§

fn from(context: &'a Context<'_>) -> Self

Converts to this type from the input type.
source§

impl<A: ExternalClone, T: ComponentBorrow, U: ComponentBorrow + Subset> From<&SubWorldRaw<A, T>> for SubWorldRaw<A, U>

source§

fn from(value: &SubWorldRaw<A, T>) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, T: ComponentBorrow, U: ComponentBorrow + Subset> From<&'b SubWorldRaw<AtomicRef<'a, World>, T>> for SubWorldRef<'b, U>

source§

fn from(subworld: &'b SubWorld<'a, T>) -> Self

Converts to this type from the input type.
source§

impl<A, T> From<A> for SubWorldRaw<A, T>

source§

fn from(world: A) -> Self

Converts to this type from the input type.
source§

impl<A: Deref<Target = World>, T: ComponentBorrow> GenericWorld for SubWorldRaw<A, T>

source§

fn reserve(&self) -> Entity

Reserve an entity

source§

fn to_ref<U: ComponentBorrow + Subset>(&self) -> SubWorldRef<'_, U>

Convert the subworld into another holding an internal reference to the original world.
source§

fn try_query<Q: Query + Subset>(&self) -> Result<QueryBorrow<'_, Q>>

Queries the world
source§

fn try_query_one<Q: Query + Subset>( &self, entity: Entity ) -> Result<QueryOne<'_, Q>>

Queries the world for a specific entity
source§

fn try_get<C: Component>(&self, entity: Entity) -> Result<Ref<'_, C>>

Get a single component for an entity Returns the contextual result since hecs-schedule is required to be imported anyway
source§

fn try_get_mut<C: Component>(&self, entity: Entity) -> Result<RefMut<'_, C>>

Get a single component for an entity Returns the contextual result since hecs-schedule is required to be imported anyway
source§

fn to_empty(&self) -> EmptyWorld<'_>

Transform this into a subworld which borrows no components. This is useful for concurrent access of entities.
source§

impl<'a, A, T> View<'a> for SubWorldRaw<A, T>
where A: Deref<Target = World>, T: ComponentBorrow,

§

type Superset = A

The type which View comes from
source§

fn split(world: Self::Superset) -> Self

Splits from the containing superset

Auto Trait Implementations§

§

impl<A, T> RefUnwindSafe for SubWorldRaw<A, T>

§

impl<A, T> Send for SubWorldRaw<A, T>
where A: Send, T: Send,

§

impl<A, T> Sync for SubWorldRaw<A, T>
where A: Sync, T: Sync,

§

impl<A, T> Unpin for SubWorldRaw<A, T>
where A: Unpin, T: Unpin,

§

impl<A, T> UnwindSafe for SubWorldRaw<A, T>
where A: UnwindSafe, T: UnwindSafe,

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> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
source§

impl<T> Component for T
where T: Send + Sync + 'static,