[][src]Crate restor

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 RefCells. 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 an Err(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 an Ok(x).

Structs

BlackBox

The base structure for this library, contains all of the dynamically typed storage units

DynamicStorage

The newtype for storage with interior mutability based on RefCells, only allowing for it exist on one thread.

MutexStorage

The storage with interior mutability based on Mutexes. This allows the data that is put in to only need to be T: Send, because this only allows one thread to read or write to the data.

RwLockStorage

A wrapper for a RwLock-safe BlackBox that is Send + Sync!

Enums

ErrorDesc

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 the Unit variant of ErrorDesc.

UnitError

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.

FetchMultiple

An abstraction over Fetch which works over multiple types, and the six types which have Fetch pre-implemented. This is therefore implemented for the following types:

Unit

The type erasure trait for restor.