pub trait Storable: PartialEq + TypeInfo + Sealedwhere
Self: Sized,{
type HandleType: Handle;
type StoreType: StoreFor<Self>;
// Required method
fn carries_id() -> bool;
// Provided methods
fn handle(&self) -> Option<Self::HandleType> { ... }
fn handle_or_err(&self) -> Result<Self::HandleType, StamError> { ... }
fn id(&self) -> Option<&str> { ... }
fn id_or_err(&self) -> Result<&str, StamError> { ... }
fn with_id(self, id: String) -> Self
where Self: Sized { ... }
fn wrap_in<'store>(
&'store self,
store: &'store Self::StoreType
) -> Result<WrappedItem<'store, Self>, StamError>
where Self: Sized { ... }
fn wrap_owned_in<'store>(
self,
store: &'store Self::StoreType
) -> Result<WrappedItem<'store, Self>, StamError>
where Self: Sized { ... }
fn set_handle(&mut self, handle: <Self as Storable>::HandleType) { ... }
fn bound(&mut self) { ... }
fn generate_id(self, idmap: Option<&mut IdMap<Self::HandleType>>) -> Self
where Self: Sized { ... }
}Required Associated Types§
Required Methods§
sourcefn carries_id() -> bool
fn carries_id() -> bool
Does this type support an ID?
Provided Methods§
sourcefn handle(&self) -> Option<Self::HandleType>
fn handle(&self) -> Option<Self::HandleType>
Retrieve the internal (numeric) id. For any type T uses in StoreFor<T>, this may be None only in the initial
stage when it is still unbounded to a store.
sourcefn handle_or_err(&self) -> Result<Self::HandleType, StamError>
fn handle_or_err(&self) -> Result<Self::HandleType, StamError>
Like Self::handle() but returns a StamError::Unbound error if there is no internal id.
sourcefn id_or_err(&self) -> Result<&str, StamError>
fn id_or_err(&self) -> Result<&str, StamError>
Like Self::id() but returns a StamError::NoIdError error if there is no internal id.
sourcefn wrap_in<'store>(
&'store self,
store: &'store Self::StoreType
) -> Result<WrappedItem<'store, Self>, StamError>where
Self: Sized,
fn wrap_in<'store>( &'store self, store: &'store Self::StoreType ) -> Result<WrappedItem<'store, Self>, StamError>where Self: Sized,
Returns a wrapped reference to this item and the store that owns it. This allows for some
more introspection on the part of the item.
reverse of StoreFor<T>::wrap()
sourcefn wrap_owned_in<'store>(
self,
store: &'store Self::StoreType
) -> Result<WrappedItem<'store, Self>, StamError>where
Self: Sized,
fn wrap_owned_in<'store>( self, store: &'store Self::StoreType ) -> Result<WrappedItem<'store, Self>, StamError>where Self: Sized,
Returns a wrapped reference to this item and the store that owns it. This allows for some
more introspection on the part of the item.
reverse of StoreFor<T>::wrap_owned()
sourcefn set_handle(&mut self, handle: <Self as Storable>::HandleType)
fn set_handle(&mut self, handle: <Self as Storable>::HandleType)
Set the internal ID. May only be called once (though currently not enforced).
sourcefn generate_id(self, idmap: Option<&mut IdMap<Self::HandleType>>) -> Selfwhere
Self: Sized,
fn generate_id(self, idmap: Option<&mut IdMap<Self::HandleType>>) -> Selfwhere Self: Sized,
Generate a random ID in a given idmap (adds it to the map and assigns it to the item)