[−][src]Trait lv2::prelude::URIDCollection
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. #[uri("urn:my-type-a")] struct MyTypeA; #[uri("urn:my-type-b")] struct MyTypeB; // Defining the collection. #[derive(URIDCollection)] 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: &M) -> Option<Self> where
M: Map + ?Sized,
M: Map + ?Sized,
Construct the collection from the mapper.
Implementors
impl URIDCollection for AtomURIDCollection
[src]
impl URIDCollection for MidiURIDCollection
[src]
impl URIDCollection for UnitURIDCollection
[src]
impl<T> URIDCollection for URID<T> where
T: UriBound + ?Sized,
[src]
T: UriBound + ?Sized,