Struct Entity

Source
pub struct Entity { /* private fields */ }
Expand description

Represents an entity with a unique id and a generation to track lifecycle and version.

Implementations§

Source§

impl Entity

Source§

impl Entity

Source

pub const INVALID: Self

A constant representing an invalid Entity, which is the result of an invalid id.

Source

pub const fn new(id: u32, generation: u32) -> Option<Self>

Creates a new Entity with the specified id and generation if the id is valid. Returns None if the id is invalid (e.g., equals u32::MAX).

Source

pub const unsafe fn new_unchecked(id: u32, generation: u32) -> Self

§Safety

This method is unsafe because it bypasses the validity check for id and generation. It’s the caller’s responsibility to ensure the id and generation are appropriate, as an invalid id (such as u32::MAX) could cause undefined behavior in the ECS system.

Source

pub const fn is_valid(self) -> bool

Returns true if the Entity is valid, meaning the id is not equal to u32::MAX.

Source

pub const fn id(self) -> u32

Returns the id of the Entity.

Source

pub const fn generation(self) -> u32

Returns the generation of the Entity.

Source

pub const fn to_u64(self) -> u64

Converts the Entity into a u64 representation combining the generation and id.

Source

pub const fn from_u64(value: u64) -> Self

Converts a u64 value back into an Entity, decoding the generation and id.

Source§

impl Entity

Source

pub fn install(registry: &mut Registry)

Registers the Entity type and its associated methods in the given registry.

Trait Implementations§

Source§

impl Clone for Entity

Source§

fn clone(&self) -> Entity

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Entity

Source§

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

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

impl Default for Entity

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Entity

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Entity

Source§

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

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

impl FromIterator<Entity> for Multity

Source§

fn from_iter<T: IntoIterator<Item = Entity>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for Entity

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntuicioStruct for Entity

Source§

impl Ord for Entity

Source§

fn cmp(&self, other: &Entity) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Entity

Source§

fn eq(&self, other: &Entity) -> 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 PartialOrd for Entity

Source§

fn partial_cmp(&self, other: &Entity) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Entity

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a, const LOCKING: bool> TypedLookupFetch<'a, LOCKING> for Entity

Source§

type Value = Entity

Source§

type ValueOne = <Entity as TypedLookupFetch<'a, LOCKING>>::Value

Source§

type Access = &'a EntityDenseMap

Source§

fn try_access(archetype: &'a Archetype) -> Option<Self::Access>

Source§

fn fetch(access: &mut Self::Access, entity: Entity) -> Option<Self::Value>

Source§

fn fetch_one(_: &World, entity: Entity) -> Option<Self::ValueOne>

Source§

fn unique_access(output: &mut HashSet<TypeHash>)

Source§

impl<'a, const LOCKING: bool> TypedQueryFetch<'a, LOCKING> for Entity

Source§

type Value = Entity

Source§

type Access = Box<dyn Iterator<Item = Entity> + 'a>

Source§

fn does_accept_archetype(_: &Archetype) -> bool

Source§

fn access(archetype: &'a Archetype) -> Result<Self::Access, QueryError>

Source§

fn fetch(access: &mut Self::Access) -> Option<Self::Value>

Source§

fn unique_access(output: &mut HashSet<TypeHash>)

Source§

impl<'a> TypedRelationLookupFetch<'a> for Entity

Source§

type Value = Entity

Source§

type Access = Option<Entity>

Source§

fn access(_: &'a World, entity: Entity) -> Self::Access

Source§

fn fetch(access: &mut Self::Access) -> Option<Self::Value>

Source§

impl<'a> TypedRelationLookupTransform<'a> for Entity

Source§

type Input = Entity

Source§

type Output = Entity

Source§

fn transform( _: &'a World, input: Self::Input, ) -> impl Iterator<Item = Self::Output>

Source§

impl Copy for Entity

Source§

impl Eq for Entity

Source§

impl StructuralPartialEq for Entity

Auto Trait Implementations§

§

impl Freeze for Entity

§

impl RefUnwindSafe for Entity

§

impl Send for Entity

§

impl Sync for Entity

§

impl Unpin for Entity

§

impl UnwindSafe for Entity

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> Finalize for T

Source§

unsafe fn finalize_raw(data: *mut ())

Safety Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Initialize for T
where T: Default,

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

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<N> NodeTrait for N
where N: Copy + Ord + Hash,

Source§

impl<T> RuleType for T
where T: Copy + Debug + Eq + Hash + Ord,