Struct ComponentData

Source
pub struct ComponentData<C> { /* private fields */ }
Expand description

Storage for a single component type.

Implementations§

Source§

impl<C> ComponentData<C>

Source

pub fn new() -> ComponentData<C>

Construct new empty ComponentData instance.

Source

pub fn insert(&mut self, e: Entity, comp: C)

Insert a component to an entity.

Source

pub fn contains(&self, e: Entity) -> bool

Return whether an entity contains this component.

Source

pub fn get(&self, e: Entity) -> Option<&C>

Get a reference to a component only if it exists for this entity.

Source

pub fn get_mut(&mut self, e: Entity) -> Option<&mut C>

Get a mutable reference to a component only if it exists for this entity.

Source

pub fn ent_iter(&self) -> Iter<'_, Entity>

Iterate entity ids in this component.

Source

pub fn iter(&self) -> Iter<'_, C>

Iterate elements in this component.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, C>

Iterate mutable elements in this component.

Trait Implementations§

Source§

impl<C> AnyComponent for ComponentData<C>

Source§

fn remove(&mut self, e: Entity)

Remove an entity’s component.
Source§

impl<'a, C: Deserialize<'a>> Deserialize<'a> for ComponentData<C>

Source§

fn deserialize<D: Deserializer<'a>>(d: D) -> Result<Self, D::Error>

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

impl<C> Index<Entity> for ComponentData<C>

Source§

type Output = C

The returned type after indexing.
Source§

fn index(&self, e: Entity) -> &C

Performs the indexing (container[index]) operation. Read more
Source§

impl<C> IndexMut<Entity> for ComponentData<C>

Source§

fn index_mut(&mut self, e: Entity) -> &mut C

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<C: Serialize + Clone> Serialize for ComponentData<C>

Source§

fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<C> Freeze for ComponentData<C>

§

impl<C> RefUnwindSafe for ComponentData<C>
where C: RefUnwindSafe,

§

impl<C> Send for ComponentData<C>
where C: Send,

§

impl<C> Sync for ComponentData<C>
where C: Sync,

§

impl<C> Unpin for ComponentData<C>
where C: Unpin,

§

impl<C> UnwindSafe for ComponentData<C>
where C: 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,