Trait AbstractStored

Source
trait AbstractStored: Sized {
    type BareTy: Sized;

    // Required methods
    unsafe fn from_bare(bare_value: Self::BareTy, id: StoreId) -> Self;
    fn id(&self) -> Option<StoreId>;
    fn into_bare(self) -> Self::BareTy;

    // Provided method
    fn try_unwrap_into_bare(
        self,
        expected_store_id: StoreId,
    ) -> Result<Self::BareTy, RuntimeError> { ... }
}
Expand description

A trait for types that might have a StoreId attached to them, so-called stored types.

Required Associated Types§

Required Methods§

Source

unsafe fn from_bare(bare_value: Self::BareTy, id: StoreId) -> Self

Creates a new stored object

§Safety

The caller has to guarantee that the bare value comes from a Store with the given StoreId.

Source

fn id(&self) -> Option<StoreId>

Gets the id of this stored object

Not all stored objects require to have an id attached to them.

Source

fn into_bare(self) -> Self::BareTy

Converts this stored object into its bare form that does not have any StoreId attached to it.

Provided Methods§

Source

fn try_unwrap_into_bare( self, expected_store_id: StoreId, ) -> Result<Self::BareTy, RuntimeError>

Checks if this stored object comes from a specific store by its StoreId. If true, it converts self into its bare form, otherwise an error is returned.

§Errors

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§