Trait stam::StoreFor

source ·
pub trait StoreFor<T: Storable>: Configurable + StoreCallbacks<T> + Sealed<T> {
Show 17 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 add(self, item: T) -> Result<Self, StamError> where Self: Sized { ... } fn has(&self, item: impl Request<T>) -> bool { ... } unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T> { ... } fn get(&self, item: impl Request<T>) -> Result<&T, StamError> { ... } fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError> { ... } fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError> { ... } fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError> { ... } fn iter(&self) -> StoreIter<'_, T> where T: Storable<StoreType = Self> { ... } fn iter_mut(&mut self) -> StoreIterMut<'_, T> { ... } fn next_handle(&self) -> T::HandleType { ... } fn last_handle(&self) -> T::HandleType { ... }
}
Expand description

This trait is implemented on types that provide storage for a certain other generic type (T) It belongs to the low-level API. 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 This is a low-level API method.

source

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

Get a mutable reference to the entire store for the associated type This is a low-level API method.

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 This is a low-level API method.

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 This is a low-level API method.

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 add(self, item: T) -> Result<Self, StamError>
where Self: Sized,

Inserts items into the store using a builder pattern

source

fn has(&self, item: impl Request<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(&self, item: impl Request<T>) -> Result<&T, StamError>

Get a reference to an item from the store This is a low-level API method, you usually want to use dedicated high-level methods like AnnotationStore::annotation() instead.

source

fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>

Get a mutable reference to an item from the store by internal ID This is a low-level API method

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 resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>

Resolves an ID to a handle. Also works for temporary IDs if enabled. This is a low-level API method. You usually don’t want to call this directly.

source

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

Iterate over all items in the store This is a low-level API method, use dedicated high-level iterators like annotations(), resources() instead.

source

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

Iterate over the store, mutably This is a low-level API method.

source

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

Return the internal id that will be assigned for the next item to the store This is a low-level API method.

source

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

Return the internal id that was assigned to last inserted item This is a low-level API method.

Object Safety§

This trait is not object safe.

Implementors§