Skip to main content

EntityBundleMap

Struct EntityBundleMap 

Source
pub struct EntityBundleMap<I: EntityId, T> { /* private fields */ }
Expand description

A map where each key-value pair is assigned a contiguous range of IDs.

An EntityBundleMap is a collection of bundles. Each bundle consists of a key, a value, and a range of IDs assigned to it. The amount of IDs assigned to a bundle is determined by its shape: an array of a specified size, or just a single unit.

Note that we distinguish between a single unit and an array of size one. This is intentional, as this datastructure is used to implement data models that make this distinction, much like Rust makes a distinction between u32 and [u32; 1].

Implementations§

Source§

impl<I: EntityId, T> EntityBundleMap<I, T>

Source

pub fn new() -> Self

Source

pub fn is_empty(&self) -> bool

Source

pub fn ids(&self) -> impl DoubleEndedIterator<Item = I> + '_

Source

pub fn get(&self, key: &str) -> Option<(EntityBundleIndices<I>, &T)>

Retrieve a bundle by its key.

Source

pub fn get_mut(&mut self, key: &str) -> Option<(EntityBundleIndices<I>, &mut T)>

Source

pub fn contains_key(&self, key: &str) -> bool

Source

pub fn key(&self, id: I) -> (&str, EntityBundleItemIndex)

Given an ID, returns the key of the bundle which owns that ID, as well as the particular position within the bundle that corresponds to the ID.

Source

pub fn insert( &mut self, ids: impl Into<EntityBundleIndices<I>>, name: String, value: T, ) -> Result<(), DuplicateKeyError>

Insert a bundle.

Source

pub fn iter(&self) -> impl Iterator<Item = (I, &str, EntityBundleItemIndex, &T)>

Source

pub fn bundles( &self, ) -> impl Iterator<Item = (EntityBundleIndices<I>, &str, &T)>

Source

pub fn bundles_mut( &mut self, ) -> impl Iterator<Item = (EntityBundleIndices<I>, &str, &mut T)>

Source

pub fn into_bundles( self, ) -> impl Iterator<Item = (EntityBundleIndices<I>, String, T)>

Trait Implementations§

Source§

impl<I: Clone + EntityId, T: Clone> Clone for EntityBundleMap<I, T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<I: Debug + EntityId, T: Debug> Debug for EntityBundleMap<I, T>

Source§

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

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

impl<I: EntityId, T> Default for EntityBundleMap<I, T>

Source§

fn default() -> Self

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

impl<I: Eq + EntityId, T: Eq> Eq for EntityBundleMap<I, T>

Source§

impl<I: EntityId, T> Index<I> for EntityBundleMap<I, T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: I) -> &Self::Output

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

impl<I: EntityId, T> IndexMut<I> for EntityBundleMap<I, T>

Source§

fn index_mut(&mut self, index: I) -> &mut Self::Output

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

impl<I: PartialEq + EntityId, T: PartialEq> PartialEq for EntityBundleMap<I, T>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<I: PartialEq + EntityId, T: PartialEq> StructuralPartialEq for EntityBundleMap<I, T>

Auto Trait Implementations§

§

impl<I, T> Freeze for EntityBundleMap<I, T>

§

impl<I, T> RefUnwindSafe for EntityBundleMap<I, T>

§

impl<I, T> Send for EntityBundleMap<I, T>
where T: Send,

§

impl<I, T> Sync for EntityBundleMap<I, T>
where T: Sync,

§

impl<I, T> Unpin for EntityBundleMap<I, T>
where I: Unpin, T: Unpin,

§

impl<I, T> UnsafeUnpin for EntityBundleMap<I, T>

§

impl<I, T> UnwindSafe for EntityBundleMap<I, T>
where I: UnwindSafe, 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
§

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

§

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

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

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

§

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

Compare self to key and return true if they are equal.
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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.