restor
A dyamic resource storage written in rust. It supports storage of multiple types and multiple entries and dynamic borrow checking with the help of RefCell
s, Mutex
s and RwLock
s from parking_lot
. It also supports extracting and aqcuiring multiple types at once.
Example:
use ;
How it works:
BlackBox
(Or DynamicStorage
) is defined as so (More or less):
The Unit
trait allows us to abstract over the generic type of the container (Referred to as UnitStorage
in the code), so we can pass data in and out of it by using the seemingly magical Any
trait. When you insert something into the storage it goes through these stages:
- Your data in
BlackBox::insert<T>
- Boxed into a
Box<dyn Any>
- Passed to the
StorageUnit as dyn Unit
- Try to downcast as either a
T
or aVec<T>
- Put into its own place in the storage or in a
Vec