pub struct Relation<T: Component> { /* private fields */ }Expand description
Represents a relationship between entities with associated metadata (payload).
Implementations§
Source§impl<T: Component> Relation<T>
impl<T: Component> Relation<T>
Sourcepub fn install_to_registry(registry: &mut Registry)
pub fn install_to_registry(registry: &mut Registry)
Installs the relation type into the provided registry for entity processing.
Sourcepub fn register_to_processor(processor: &mut WorldProcessor)
pub fn register_to_processor(processor: &mut WorldProcessor)
Registers relation-specific entity remapping and inspection logic with the processor.
Sourcepub fn register_to_processor_debug(processor: &mut WorldProcessor)where
T: Debug,
pub fn register_to_processor_debug(processor: &mut WorldProcessor)where
T: Debug,
Registers debug-specific formatting for this relation in the processor.
Sourcepub fn new(payload: T, entity: Entity) -> Self
pub fn new(payload: T, entity: Entity) -> Self
Creates a new relation with a single connection.
Sourcepub fn with(self, payload: T, entity: Entity) -> Self
pub fn with(self, payload: T, entity: Entity) -> Self
Adds a connection to the relation and returns the modified relation.
Sourcepub fn add(&mut self, payload: T, entity: Entity)
pub fn add(&mut self, payload: T, entity: Entity)
Adds a connection to the relation, updating or inserting as necessary.
Sourcepub fn has(&self, entity: Entity) -> bool
pub fn has(&self, entity: Entity) -> bool
Checks if the relation has a connection with the given entity.
Sourcepub fn payload(&self, entity: Entity) -> Option<&T>
pub fn payload(&self, entity: Entity) -> Option<&T>
Gets the payload associated with the given entity.
Sourcepub fn payload_mut(&mut self, entity: Entity) -> Option<&mut T>
pub fn payload_mut(&mut self, entity: Entity) -> Option<&mut T>
Gets a mutable reference to the payload associated with the given entity.
Sourcepub fn entities(&self) -> impl Iterator<Item = Entity> + '_
pub fn entities(&self) -> impl Iterator<Item = Entity> + '_
Returns an iterator over all entities in the relation.
Trait Implementations§
Source§impl<T: Ord + Component> Ord for Relation<T>
impl<T: Ord + Component> Ord for Relation<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd + Component> PartialOrd for Relation<T>
impl<T: PartialOrd + Component> PartialOrd for Relation<T>
impl<T: Eq + Component> Eq for Relation<T>
impl<T: Component> StructuralPartialEq for Relation<T>
Auto Trait Implementations§
impl<T> Freeze for Relation<T>where
T: Freeze,
impl<T> RefUnwindSafe for Relation<T>where
T: RefUnwindSafe,
impl<T> Send for Relation<T>
impl<T> Sync for Relation<T>
impl<T> Unpin for Relation<T>where
T: Unpin,
impl<T> UnwindSafe for Relation<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.