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§
sourcefn store_mut(&mut self) -> &mut Store<T>
fn store_mut(&mut self) -> &mut Store<T>
Get a mutable reference to the entire store for the associated type
fn store_typeinfo() -> &'static str
Provided Methods§
sourcefn idmap(&self) -> Option<&IdMap<T::HandleType>>
fn idmap(&self) -> Option<&IdMap<T::HandleType>>
Get a reference to the id map for the associated type, mapping global ids to internal ids
sourcefn idmap_mut(&mut self) -> Option<&mut IdMap<T::HandleType>>
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
sourcefn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
Adds an item to the store. Returns a handle to it upon success.
sourcefn preinsert(&self, item: &mut T) -> Result<(), StamError>
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
sourcefn inserted(&mut self, handle: T::HandleType) -> Result<(), StamError>
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
fn add(self, item: T) -> Result<Self, StamError>where Self: Sized,
sourceunsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
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. │
sourcefn get<'a, 'b>(&'a self, item: &Item<'b, T>) -> Result<&'a T, StamError>
fn get<'a, 'b>(&'a self, item: &Item<'b, T>) -> Result<&'a T, StamError>
Get a reference to an item from the store
sourcefn get_mut<'a, 'b>(&mut self, item: &Item<'b, T>) -> Result<&mut T, StamError>
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
sourcefn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
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
sourcefn preremove(&mut self, handle: T::HandleType) -> Result<(), StamError>
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
sourcefn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
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
sourcefn owns(&self, item: &T) -> Option<bool>
fn owns(&self, item: &T) -> Option<bool>
Tests if the item is owner by the store, returns None if ownership is unknown
sourcefn iter<'a>(&'a self) -> StoreIter<'a, T> ⓘwhere
T: Storable<StoreType = Self>,
fn iter<'a>(&'a self) -> StoreIter<'a, T> ⓘwhere T: Storable<StoreType = Self>,
Iterate over the store
sourcefn iter_mut<'a>(&'a mut self) -> StoreIterMut<'a, T> ⓘ
fn iter_mut<'a>(&'a mut self) -> StoreIterMut<'a, T> ⓘ
Iterate over the store, mutably
sourcefn next_handle(&self) -> T::HandleType
fn next_handle(&self) -> T::HandleType
Return the internal id that will be assigned for the next item to the store
sourcefn last_handle(&self) -> T::HandleType
fn last_handle(&self) -> T::HandleType
Return the internal id that was assigned to last inserted item
sourcefn bind(&mut self, item: T) -> Result<T, StamError>
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).
sourcefn wrap<'a>(&'a self, item: &'a T) -> Result<WrappedItem<'_, T>, StamError>where
T: Storable<StoreType = Self>,
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.
sourcefn wrap_owned<'a>(&'a self, item: 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>,
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.
sourcefn wrap_store<'a>(&'a self) -> WrappedStore<'_, T, Self>where
Self: Sized,
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