[][src]Struct mecs::entity::Entity

pub struct Entity<'a, S> where
    S: Storage<'a>,
    S::Id: KeyType, 
{ /* fields omitted */ }

An entity

Methods

impl<'a, S> Entity<'a, S> where
    S: Storage<'a>,
    S::Id: KeyType, 
[src]

#[must_use] pub fn new() -> Self[src]

Creates an empty entity

#[must_use] pub fn from_components(components: Vec<S>) -> Self[src]

Creates an entity from a list of components

pub fn add(&mut self, storage: S) -> Option<S>[src]

Adds a new component to this entity

Return

If this entity already contains a component with the same id as the one in storage, it is returned.

pub fn remove<C: Component<'a, S>>(&mut self) -> Option<S>[src]

Remove a component from this entity given it's type

pub fn remove_id(&mut self, id: &S::Id) -> Option<S>[src]

Removes a component from this entity given it's id

#[must_use] pub fn get<C: Component<'a, S>>(&self) -> Option<&C>[src]

Returns a reference to a component given it's type

Return

If either the component is not present in this entity or the component could not be build from the storage associated with it's id, this function will return None.

#[must_use] pub fn get_mut<C: Component<'a, S>>(&mut self) -> Option<&mut C>[src]

Returns a mutable reference to a component given it's type

Return

If either the component is not present in this entity or the component could not be build from the storage associated with it's id, this function will return None.

#[must_use] pub fn get_id(&self, id: &S::Id) -> Option<&S>[src]

Returns a reference to a component's storage given it's id

#[must_use] pub fn get_mut_id(&mut self, id: &S::Id) -> Option<&mut S>[src]

Returns a mutable reference to a component's storage given it's id

pub fn ids(&self) -> impl Iterator<Item = &<S as Storage<'a>>::Id>[src]

Returns an iterator over all component ids in this entity

#[must_use] pub fn components(&self) -> Values<S::Id, S>[src]

Returns an iterator over all components in this entity

#[must_use] pub fn components_mut(&mut self) -> ValuesMut<S::Id, S>[src]

Returns a mutable iterator over all components in this entity

#[must_use] pub fn has<C: Component<'a, S>>(&self) -> bool[src]

Checks if this entity has a component given it's type

#[must_use] pub fn has_id(&self, id: &S::Id) -> bool[src]

Checks if this entity has a component given it's id

Trait Implementations

impl<'a, S: Clone> Clone for Entity<'a, S> where
    S: Storage<'a>,
    S::Id: KeyType,
    S::Id: Clone
[src]

impl<'a, S: Debug> Debug for Entity<'a, S> where
    S: Storage<'a>,
    S::Id: KeyType,
    S::Id: Debug
[src]

impl<'a, S> Default for Entity<'a, S> where
    S: Storage<'a>,
    S::Id: KeyType, 
[src]

impl<'a, S: Eq> Eq for Entity<'a, S> where
    S: Storage<'a>,
    S::Id: KeyType,
    S::Id: Eq
[src]

impl<'a, S: PartialEq> PartialEq<Entity<'a, S>> for Entity<'a, S> where
    S: Storage<'a>,
    S::Id: KeyType,
    S::Id: PartialEq
[src]

impl<'a, S> StructuralEq for Entity<'a, S> where
    S: Storage<'a>,
    S::Id: KeyType, 
[src]

impl<'a, S> StructuralPartialEq for Entity<'a, S> where
    S: Storage<'a>,
    S::Id: KeyType, 
[src]

Auto Trait Implementations

impl<'a, S> RefUnwindSafe for Entity<'a, S> where
    S: RefUnwindSafe,
    <S as Storage<'a>>::Id: RefUnwindSafe

impl<'a, S> Send for Entity<'a, S> where
    S: Send,
    <S as Storage<'a>>::Id: Send

impl<'a, S> Sync for Entity<'a, S> where
    S: Sync,
    <S as Storage<'a>>::Id: Sync

impl<'a, S> Unpin for Entity<'a, S> where
    S: Unpin,
    <S as Storage<'a>>::Id: Unpin

impl<'a, S> UnwindSafe for Entity<'a, S> where
    S: UnwindSafe,
    <S as Storage<'a>>::Id: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Component<'static, DynStorage> for T where
    T: Debug + 'static, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.