[][src]Trait urid::URIDCollection

pub trait URIDCollection: Sized {
    fn from_map<M: Map + ?Sized>(map: &M) -> Option<Self>;

A store of pre-mapped URIDs

This trait can be used to easily cache URIDs. The usual way of creating such a collection is to define a struct of URID<T>s, where T implements UriBound, and then using the derive macro to implement URIDCollection for it. Then, you can populate it with a map and access it any time, even in a real-time-sensitive context.

Usage example:

// Defining all URI bounds.
struct MyTypeA;
struct MyTypeB;

// Defining the collection.
struct MyCollection {
    my_type_a: URID<MyTypeA>,
    my_type_b: URID<MyTypeB>,

// Creating a mapper and collecting URIDs.
let map = HashURIDMapper::new();
let collection = MyCollection::from_map(&map).unwrap();

// Asserting.
assert_eq!(1, collection.my_type_a);
assert_eq!(2, collection.my_type_b);

Required methods

fn from_map<M: Map + ?Sized>(map: &M) -> Option<Self>

Construct the collection from the mapper.

Loading content...


impl<T: UriBound + ?Sized> URIDCollection for URID<T>[src]

Loading content...