Trait stam::StoreFor

source ·
pub trait StoreFor<T: Storable>: Configurable + Sealed<T> {
Show 25 methods // Required methods fn store(&self) -> &Store<T>; fn store_mut(&mut self) -> &mut Store<T>; fn store_typeinfo() -> &'static str; // Provided methods fn idmap(&self) -> Option<&IdMap<T::HandleType>> { ... } fn idmap_mut(&mut self) -> Option<&mut IdMap<T::HandleType>> { ... } fn insert(&mut self, item: T) -> Result<T::HandleType, StamError> { ... } fn preinsert(&self, item: &mut T) -> Result<(), StamError> { ... } fn inserted(&mut self, handle: T::HandleType) -> Result<(), StamError> { ... } fn add(self, item: T) -> Result<Self, StamError> where Self: Sized { ... } fn has<'a, 'b>(&'a self, item: &Item<'b, T>) -> bool { ... } unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T> { ... } fn get<'a, 'b>(&'a self, item: &Item<'b, T>) -> Result<&'a T, StamError> { ... } fn get_mut<'a, 'b>( &mut self, item: &Item<'b, T> ) -> Result<&mut T, StamError> { ... } fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError> { ... } fn preremove(&mut self, handle: T::HandleType) -> Result<(), StamError> { ... } fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError> { ... } fn owns(&self, item: &T) -> Option<bool> { ... } fn iter<'a>(&'a self) -> StoreIter<'a, T> where T: Storable<StoreType = Self> { ... } fn iter_mut<'a>(&'a mut self) -> StoreIterMut<'a, T> { ... } fn next_handle(&self) -> T::HandleType { ... } fn last_handle(&self) -> T::HandleType { ... } fn bind(&mut self, item: T) -> Result<T, StamError> { ... } fn wrap<'a>(&'a self, item: &'a T) -> Result<WrappedItem<'_, T>, StamError> where T: Storable<StoreType = Self> { ... } fn wrap_owned<'a>( &'a self, item: T ) -> Result<WrappedItem<'_, T>, StamError> where T: Storable<StoreType = Self> { ... } fn wrap_store<'a>(&'a self) -> WrappedStore<'_, T, Self> where Self: Sized { ... }
}
Expand description

This trait is implemented on types that provide storage for a certain other generic type (T) It is a sealed trait, not implementable outside this crate.

Required Methods§

source

fn store(&self) -> &Store<T>

Get a reference to the entire store for the associated type

source

fn store_mut(&mut self) -> &mut Store<T>

Get a mutable reference to the entire store for the associated type

source

fn store_typeinfo() -> &'static str

Provided Methods§

source

fn idmap(&self) -> Option<&IdMap<T::HandleType>>

Get a reference to the id map for the associated type, mapping global ids to internal ids

source

fn idmap_mut(&mut self) -> Option<&mut IdMap<T::HandleType>>

Get a mutable reference to the id map for the associated type, mapping global ids to internal ids

source

fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>

Adds an item to the store. Returns a handle to it upon success.

source

fn preinsert(&self, item: &mut T) -> Result<(), StamError>

Called prior to inserting an item into to the store If it returns an error, the insert will be cancelled. Allows for bookkeeping such as inheriting configuration parameters from parent to the item

source

fn inserted(&mut self, handle: T::HandleType) -> Result<(), StamError>

Called after an item was inserted to the store Allows the store to do further bookkeeping like updating relation maps

source

fn add(self, item: T) -> Result<Self, StamError>where Self: Sized,

source

fn has<'a, 'b>(&'a self, item: &Item<'b, T>) -> bool

Returns true if the store has the item

source

unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>

Get a reference to an item from the store, by handle, without checking validity.

Safety

Calling this method with an out-of-bounds index is undefined behavior
even if the resulting reference is not used. │

source

fn get<'a, 'b>(&'a self, item: &Item<'b, T>) -> Result<&'a T, StamError>

Get a reference to an item from the store

source

fn get_mut<'a, 'b>(&mut self, item: &Item<'b, T>) -> Result<&mut T, StamError>

Get a mutable reference to an item from the store by internal ID

source

fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>

Removes an item by handle, returns an error if the item has dependencies and can’t be removed

source

fn preremove(&mut self, handle: T::HandleType) -> Result<(), StamError>

Called before an item is removed from the store Allows the store to do further bookkeeping like updating relation maps

source

fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>

Resolves an ID to a handle You usually don’t want to call this directly

source

fn owns(&self, item: &T) -> Option<bool>

Tests if the item is owner by the store, returns None if ownership is unknown

source

fn iter<'a>(&'a self) -> StoreIter<'a, T> where T: Storable<StoreType = Self>,

Iterate over the store

source

fn iter_mut<'a>(&'a mut self) -> StoreIterMut<'a, T>

Iterate over the store, mutably

source

fn next_handle(&self) -> T::HandleType

Return the internal id that will be assigned for the next item to the store

source

fn last_handle(&self) -> T::HandleType

Return the internal id that was assigned to last inserted item

source

fn bind(&mut self, item: T) -> Result<T, StamError>

This binds an item to the store PRIOR to it being actually added You should never need to call this directly (it can only be called once per item anyway).

source

fn wrap<'a>(&'a self, item: &'a T) -> Result<WrappedItem<'_, T>, StamError>where T: Storable<StoreType = Self>,

Wraps the item in a smart pointer that also holds a reference to this store This method performs some extra checks to verify if the item is indeed owned by the store and returns an error if not.

source

fn wrap_owned<'a>(&'a self, item: T) -> Result<WrappedItem<'_, T>, StamError>where T: Storable<StoreType = Self>,

Wraps the item in a smart pointer that also holds a reference to this store Ownership is retained with this method, i.e. the store does NOT own the item.

source

fn wrap_store<'a>(&'a self) -> WrappedStore<'_, T, Self>where Self: Sized,

Wraps the entire store along with a reference to self Low-level method that you won’t need

Implementors§