Struct despero::ecs::SubWorldRaw

source ·
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) -> SubWorldRaw<A, T>

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

source§

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

source

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

Returns true if the subworld can access the borrow of T

source

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

Returns true if the world satisfies the whole query

source§

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

source

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

Query the subworld.

Panics

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

source

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

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

source

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

Get a single component from the world.

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

source

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

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>(&self) -> QueryBorrow<'_, Q>where Q: Query + Subset,

Query the subworld.

Panics

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

source§

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

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, T> SubWorldRaw<A, T>where A: ExternalClone, T: ComponentBorrow,

source

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

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

Trait Implementations§

source§

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

source§

fn borrows() -> SmallVec<[Access; 8]>

Returns a list of all component accesses
source§

fn has<U>() -> boolwhere U: IntoAccess,

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> ContextBorrow<'a> for SubWorldRaw<AtomicRef<'a, World>, T>

§

type Target = SubWorldRaw<AtomicRef<'a, World>, T>

The resulting type after borrowing from context
source§

fn borrow( context: &'a Context<'_> ) -> Result<SubWorldRaw<AtomicRef<'a, World>, T>, Error>

Borrow type from context
source§

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

source§

fn from(context: &'a Context<'_>) -> SubWorldRaw<AtomicRef<'a, World>, T>

Converts to this type from the input type.
source§

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

source§

fn from( subworld: &'b SubWorldRaw<AtomicRef<'a, World>, T> ) -> SubWorldRaw<&'b World, U>

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

fn from(world: A) -> SubWorldRaw<A, T>

Converts to this type from the input type.
source§

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

source§

fn reserve(&self) -> Entity

Reserve an entity

source§

fn to_ref<U>(&self) -> SubWorldRaw<&World, U>where U: ComponentBorrow + Subset,

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

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

Queries the world
source§

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

Queries the world for a specific entity
source§

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

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>(&self, entity: Entity) -> Result<RefMut<'_, C>, Error>where C: Component,

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) -> SubWorldRaw<&World, ()>

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

impl<T> IntoBorrow for SubWorldRaw<AtomicRef<'_, World>, T>where T: Component,

§

type Borrow = SubWorldBorrower<T>

The borrow type
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: <SubWorldRaw<A, T> as View<'a>>::Superset) -> SubWorldRaw<A, T>

Splits from the containing superset

Auto Trait Implementations§

§

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

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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.

§

impl<T> FromFd for Twhere T: From<OwnedFd>,

§

fn from_fd(owned_fd: OwnedFd) -> T

👎Deprecated since 1.0.0: FromFd::from_fd is replaced by From<OwnedFd>::from
Constructs a new instance of Self from the given file descriptor. Read more
§

fn from_into_fd<Owned>(into_owned: Owned) -> Selfwhere Owned: Into<OwnedFd>, Self: Sized + From<OwnedFd>,

Constructs a new instance of Self from the given file descriptor converted from into_owned. Read more
§

impl<T> FromFilelike for Twhere T: From<OwnedFd>,

§

fn from_filelike(owned: OwnedFd) -> T

Constructs a new instance of Self from the given filelike object. Read more
§

fn from_into_filelike<Owned>(owned: Owned) -> Twhere Owned: IntoFilelike,

Constructs a new instance of Self from the given filelike object converted from into_owned. Read more
§

impl<T> FromSocketlike for Twhere T: From<OwnedFd>,

§

fn from_socketlike(owned: OwnedFd) -> T

Constructs a new instance of Self from the given socketlike object.
§

fn from_into_socketlike<Owned>(owned: Owned) -> Twhere Owned: IntoSocketlike,

Constructs a new instance of Self from the given socketlike object converted from into_owned.
source§

impl<T> Instrument for T

source§

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

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

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 Twhere 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 = mem::align_of::<T>()

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> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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> WithSubscriber for T

source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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