pub struct ObjectTable<T> { /* private fields */ }Expand description
Bounded generational object table for one resource kind.
Kind tags, generations, and device namespaces occupy separate token fields. A slot is retired before generation overflow, so an old ID cannot become valid again after wraparound.
Implementations§
Source§impl<T> ObjectTable<T>
impl<T> ObjectTable<T>
pub const fn new(kind: ObjectKind, max_slots: u32) -> Self
pub const fn with_namespace( kind: ObjectKind, max_slots: u32, namespace: ObjectNamespace, ) -> Self
pub const fn len(&self) -> u32
pub const fn is_empty(&self) -> bool
Sourcepub fn ids(&self) -> impl Iterator<Item = ObjectId> + '_
pub fn ids(&self) -> impl Iterator<Item = ObjectId> + '_
Borrow the currently occupied identities without allocating.
IDs retain this table’s namespace, resource kind and current generation. Vacant and permanently retired slots are skipped. IDs are yielded in ascending slot index order. The iterator borrows the table, so mutation requires ending the iteration first; a saved ID must still pass ordinary lookup checks after subsequent mutation.
pub fn insert(&mut self, value: T) -> Result<ObjectId, ObjectTableError>
Sourcepub fn try_reserve_insert(&mut self) -> Result<(), ObjectTableError>
pub fn try_reserve_insert(&mut self) -> Result<(), ObjectTableError>
Reserve all capacity required by the next insertion without changing table state.
pub fn get(&self, id: ObjectId) -> Result<&T, ObjectTableError>
pub fn get_mut(&mut self, id: ObjectId) -> Result<&mut T, ObjectTableError>
pub fn remove(&mut self, id: ObjectId) -> Result<T, ObjectTableError>
Auto Trait Implementations§
impl<T> Freeze for ObjectTable<T>
impl<T> RefUnwindSafe for ObjectTable<T>where
T: RefUnwindSafe,
impl<T> Send for ObjectTable<T>where
T: Send,
impl<T> Sync for ObjectTable<T>where
T: Sync,
impl<T> Unpin for ObjectTable<T>where
T: Unpin,
impl<T> UnsafeUnpin for ObjectTable<T>
impl<T> UnwindSafe for ObjectTable<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