Expand description
A dynamically allocated storage system. Check it out on Github, or its capabilities on the
tests. This is meant to serve as a storage solution for resources in a dynamic context. It
supports runtime borrow checking using RefCell
s. It will support a concurrent context in
the future.
§Example
let mut storage = DynamicStorage::new();
storage.allocate_for::<usize>();
storage.allocate_for::<String>();
storage.insert::<String>("abc".into());
let mut my_string = storage.get::<&mut String>().unwrap();
storage.insert_many::<usize>(vec![2, 4, 8, 16, 32]);
for i in storage.get::<&[usize]>().unwrap().iter() {
*my_string = format!("{}, {:?}", &*my_string, i);
}
assert_eq!("abc, 2, 4, 8, 16, 32", &*my_string);
Macros§
- err
- A shorthand for unwrapping a
Result
into anErr(x)
. - make_
storage - Shorthand for forming storage with preallocated types.
It will also wrap it in an
Arc
(More below) - ok
- A shorthand for unwrapping a
Result
into anOk(x)
.
Structs§
- Black
Box - The base structure for this library, contains all of the dynamically typed storage units
- Dynamic
Storage - The newtype for storage with interior mutability based on
RefCell
s, only allowing for it exist on one thread. - Mutex
Storage - The storage with interior mutability based on
Mutex
es. This allows the data that is put in to only need to beT: Send
, because this only allows one thread to read or write to the data. - RwLock
Storage - A wrapper for a
RwLock
-safeBlackBox
that isSend
+Sync
!
Enums§
- Error
Desc - The basic error descriptions for why a dynamically typed resource operation didn’t work. It does
not contain however, the description for unit-related errors which handled with a
UnitError
by using theUnit
variant ofErrorDesc
. - Unit
Error - Miscellaneous errors pertaining to the internal
StorageUnit
, such as an out of bounds error, or improper accessing of data.
Traits§
- Fetch
- The base “get” trait for acquiring data from storage. This is implemented on six types, each of which have a different output. The output is dependent on the type it is being implemented for.
- Fetch
Multiple - An abstraction over
Fetch
which works over multiple types, and the six types which haveFetch
pre-implemented. This is therefore implemented for the following types: - Unit
- The type erasure trait for
restor
.