pub struct LocalMaps<'a> { /* private fields */ }
Expand description
A data structure which maintains LocalMap
s for every applicable type.
If you need to use Document::local_map
for many different types,
it may be more efficient to use this type, which calculates all maps
in a single pass.
Implementations§
Source§impl<'a> LocalMaps<'a>
impl<'a> LocalMaps<'a>
Sourcepub fn set<T: HasId + 'a>(self) -> Self
pub fn set<T: HasId + 'a>(self) -> Self
Enable collection for the given type. This is used as part of a builder-style API for
customizing collection before performing the collection pass.
For example, if we only want to collect Geometry
and Source
types:
let maps = LocalMaps::default()
.set::<Geometry>()
.set::<Source>()
.collect(&doc);
Sourcepub fn unset<T: HasId + 'a>(self) -> Self
pub fn unset<T: HasId + 'a>(self) -> Self
Disable collection for the given type. This is used as part of a builder-style API for
customizing collection before performing the collection pass.
For example, if we want to collect everything except the ForceField
and Sampler
types:
let maps = LocalMaps::new()
.unset::<ForceField>()
.unset::<Sampler>()
.collect(&doc);
Sourcepub fn collect(self, t: &'a Document) -> Self
pub fn collect(self, t: &'a Document) -> Self
Run the collection pass, putting all elements in the given IDs based on their types.
Sourcepub fn get_name<T: HasId + ?Sized>(&self, n: &NameRef<T>) -> Option<&'a T>
pub fn get_name<T: HasId + ?Sized>(&self, n: &NameRef<T>) -> Option<&'a T>
Look up an element by ID, in a NameRef
.
Sourcepub fn get_raw<T: HasId + ?Sized>(&self, url: &Url) -> Option<&'a T>
pub fn get_raw<T: HasId + ?Sized>(&self, url: &Url) -> Option<&'a T>
Look up an element by URL reference.
This is a local map, meaning that it does not support references to URLs which are not
of the special form #ref
, referring to an element with ID ref
in the same document.
Sourcepub fn get<T: HasId + ?Sized>(&self, url: &UrlRef<T>) -> Option<&'a T>
pub fn get<T: HasId + ?Sized>(&self, url: &UrlRef<T>) -> Option<&'a T>
Look up an element by URL reference.
This is a simple wrapper around get_raw
,
but it has better type safety, since it ensures that the reference is a reference to a T
.
This is a local map, meaning that it does not support references to URLs which are not
of the special form #ref
, referring to an element with ID ref
in the same document.