[−][src]Trait urid::Map
A handle to map URIs to URIDs.
Required methods
fn map_uri(&self, uri: &Uri) -> Option<URID>
Maps an URI to a URID
that corresponds to it.
If the URI has not been mapped before, a new URID will be assigned.
Errors
This method may return None
in the exceptional case that an ID for that URI could not be
created for whatever reason.
However, implementations SHOULD NOT return None
from this function in non-exceptional
circumstances (i.e. the URI map SHOULD be dynamic).
Realtime usage
This action may not be realtime-safe since it may involve locking mutexes or allocating dynamic memory. If you are working in a realtime environment, you should cache mapped URIDs in a URIDCollection
and use it instead.
Provided methods
fn map_str(&self, uri: &str) -> Option<URID>
Map an URI, encoded as a str
to a URID
that corresponds to it.
This function copies the string into a vector, adds a null terminator and calls map_uri
with it. Therefore, the rules of map_uri
apply here too.
Additional Errors
This method has the same error cases as map_uri
, but also returns None
if the string isn't an ASCII string or if the string can not be converted to a Uri
.
fn map_type<T: UriBound + ?Sized>(&self) -> Option<URID<T>>
Retrieve the URI of the bound and map it to a URID.
The rules of map_uri
apply here too.
fn populate_collection<T: URIDCollection>(&self) -> Option<T>
Populate a URID collection.
This is basically an alias for T::from_map(self)
that simplifies the derive macro for URIDCollection
.