Struct Component

Source
pub struct Component<T> { /* private fields */ }
Expand description

Defines a strongly typed component.

Implements a read only fetch when used as part of a query

Use .as_mut() to acquire a mutable fetch.

Implementations§

Source§

impl<T: ComponentValue> Component<T>

Source

pub fn key(&self) -> ComponentKey

Get the component’s id.

Source

pub fn id(&self) -> Entity

Get the component’s base id. This is the id without any relation target

Source

pub fn desc(self) -> ComponentDesc

Returns the type erased component description

Source

pub const fn as_mut(self) -> Mutable<T>

Transform this into a mutable fetch

Source

pub fn maybe_mut(self) -> MaybeMut<T>

Transform this into a (maybe) mutable fetch

Source

pub fn into_change_filter(self, kind: ChangeKind) -> ChangeFilter<T>

Construct a fine grained change detection filter.

Prefer TransformFetch if not in a const context

Source

pub fn without(self) -> Without

Construct a new filter yielding entities without this component.

Source

pub fn with(self) -> With

Construct a new filter yielding entities with this component.

Source

pub fn name(&self) -> &'static str

Get the component’s name.

Trait Implementations§

Source§

impl<T> Clone for Component<T>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Component<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Display for Component<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'w, T> Fetch<'w> for Component<T>
where T: ComponentValue,

Source§

const MUTABLE: bool = false

true if the fetch mutates any component and thus needs a change event
Source§

type Prepared = ReadComponent<'w, T>

The prepared version of the fetch
Source§

fn prepare(&self, data: FetchPrepareData<'w>) -> Option<Self::Prepared>

Prepares the fetch for an archetype by acquiring borrows. Read more
Source§

fn filter_arch(&self, data: FetchAccessData<'_>) -> bool

Returns true if the archetype matches the fetch
Source§

fn access(&self, data: FetchAccessData<'_>, dst: &mut Vec<Access>)

Returns which components and how will be accessed for an archetype.
Source§

fn describe(&self, f: &mut Formatter<'_>) -> Result

Describes the fetch in a human-readable fashion
Source§

fn searcher(&self, searcher: &mut ArchetypeSearcher)

Returns the required component for the fetch. Read more
Source§

fn by_ref(&self) -> RefFetch<'_, Self>
where Self: Sized,

Convert the fetch to a reference type which works with HRTB
Source§

impl<'q, T: ComponentValue> FetchItem<'q> for Component<T>

Source§

type Item = &'q T

The item yielded by the prepared fetch
Source§

impl<T: ComponentValue> From<Component<T>> for ComponentDesc

Source§

fn from(v: Component<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: ComponentValue> From<Component<T>> for Entity

Source§

fn from(v: Component<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: ComponentValue> Metadata<T> for Component<T>

Source§

fn attach(desc: ComponentDesc, buffer: &mut ComponentBuffer)

Attach the metadata to the component buffer
Source§

impl<T> PartialEq for Component<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: ComponentValue> RelationExt<T> for Component<T>

Source§

fn id(&self) -> Entity

Returns the relation id
Source§

fn of(&self, target: Entity) -> Component<T>

Instantiate the relation
Source§

fn with_relation(self) -> WithRelation

Construct a new filter yielding entities with this kind of relation
Source§

fn without_relation(self) -> WithoutRelation

Construct a new filter yielding entities without this kind of relation
Source§

fn vtable(&self) -> &'static UntypedVTable

Returns the vtable of the relation
Source§

fn as_relation(&self) -> Relation<T>

Convert this into a concrete relation representation
Source§

fn nth_relation(self, n: usize) -> NthRelation<T>
where Self: Sized,

Query the nth relation of the specified kind. Read more
Source§

fn first_relation(self) -> NthRelation<T>
where Self: Sized,

Query the first relation of the specified kind.
Source§

impl<T: ComponentValue> TransformFetch<Added> for Component<T>

Source§

type Output = ChangeFilter<T>

The transformed type. Read more
Source§

fn transform_fetch(self, _: Added) -> Self::Output

Transform the fetch using the provided method
Source§

impl<T: ComponentValue> TransformFetch<Modified> for Component<T>

Source§

type Output = ChangeFilter<T>

The transformed type. Read more
Source§

fn transform_fetch(self, _: Modified) -> Self::Output

Transform the fetch using the provided method
Source§

impl<T> Copy for Component<T>

Source§

impl<T> Eq for Component<T>

Auto Trait Implementations§

§

impl<T> Freeze for Component<T>

§

impl<T> RefUnwindSafe for Component<T>
where T: RefUnwindSafe,

§

impl<T> Send for Component<T>
where T: Send,

§

impl<T> Sync for Component<T>
where T: Sync,

§

impl<T> Unpin for Component<T>
where T: Unpin,

§

impl<T> UnwindSafe for Component<T>
where 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<F> FetchExt for F
where F: for<'x> Fetch<'x>,

Source§

fn opt(self) -> Opt<Self>

Transform the fetch into an optional fetch, yielding Some or None
Source§

fn opt_or<V>(self, default: V) -> OptOr<Self, V>
where for<'q> Self: for<'w> Fetch<'w> + FetchItem<'q, Item = &'q V>,

Transform the fetch into a fetch with a provided default. This is useful for default values such as scale or velocity which may not exist for every entity.
Source§

fn satisfied(self) -> Satisfied<Self>

Returns true if the query is satisfied, without borrowing
Source§

fn opt_or_default<V>(self) -> OptOr<Self, V>
where for<'q> Self: for<'w> Fetch<'w> + FetchItem<'q, Item = &'q V>, V: Default,

Transform the fetch into a fetch which yields the default impl if the fetch is not matched.
Source§

fn cloned(self) -> Cloned<Self>
where Cloned<Self>: for<'x> Fetch<'x>,

Transform this into a cloned fetch
Source§

fn copied(self) -> Copied<Self>
where Copied<Self>: for<'x> Fetch<'x>,

Transform this into a copied fetch
Source§

fn deref(self) -> AsDeref<Self>
where AsDeref<Self>: for<'x> Fetch<'x>,

Dereferences the fetch item
Source§

fn cmp<F>(self, func: F) -> Cmp<Self, F>
where for<'x> Cmp<Self, F>: Fetch<'x>,

Filter any component by predicate.
Source§

fn lt<T>(self, other: T) -> Cmp<Self, Less<T>>
where for<'x> Cmp<Self, Less<T>>: Fetch<'x>,

Filter any component less than other.
Source§

fn gt<T>(self, other: T) -> Cmp<Self, Greater<T>>
where for<'x> Cmp<Self, GreaterEq<T>>: Fetch<'x>,

Filter any component greater than other.
Source§

fn ge<T>(self, other: T) -> Cmp<Self, GreaterEq<T>>
where for<'x> Cmp<Self, GreaterEq<T>>: Fetch<'x>,

Filter any component greater than or equal to other.
Source§

fn le<T>(self, other: T) -> Cmp<Self, LessEq<T>>
where for<'x> Cmp<Self, LessEq<T>>: Fetch<'x>,

Filter any component less than or equal to other.
Source§

fn eq<T>(self, other: T) -> Cmp<Self, Equal<T>>
where for<'x> Cmp<Self, Equal<T>>: Fetch<'x>,

Filter any component equal to other.
Source§

fn source<S>(self, source: S) -> Source<Self, S>
where S: FetchSource,

Set the source entity for the fetch. Read more
Source§

fn relation<T, R>(self, relation: R) -> Source<Self, FromRelation>
where R: RelationExt<T>, T: ComponentValue,

Follows a relation to resolve the fetch. Read more
Source§

fn traverse<T, R>(self, relation: R) -> Source<Self, Traverse>
where R: RelationExt<T>, T: ComponentValue,

Traverse the edges of a relation recursively to find the first entity which matches the fetch Read more
Source§

fn modified(self) -> <Self as TransformFetch<Modified>>::Output
where Self: TransformFetch<Modified>,

Transform the fetch into a fetch where each constituent part tracks and yields for modification events. Read more
Source§

fn added(self) -> <Self as TransformFetch<Added>>::Output
where Self: TransformFetch<Added>,

Transform the fetch into a fetch where each constituent part tracks and yields for component addition events. Read more
Source§

fn map<F, T>(self, func: F) -> Map<Self, F>
where Self: for<'x> FetchItem<'x>, for<'x> F: Fn(<Self as FetchItem<'x>>::Item) -> T,

Map each item of the query to another type using the provided function.
Source§

fn filtered<F>(self, filter: F) -> Filtered<Self, F>
where F: for<'x> Fetch<'x>,

Filter a fetch with another fetch as predicate
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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

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.
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> ComponentValue for T
where T: Send + Sync + 'static,