use crate::view::{borrowed_entity, optional_text, required_text, MaterialView};
use crate::MaterialResult;
borrowed_entity!(Material, "IFCMATERIAL");
impl<'m> Material<'m> {
pub fn name(self) -> MaterialResult<&'m str> {
required_text(
"IFCMATERIAL",
self.id(),
self.entity(),
self.slot("Name")?,
"Name",
)
}
pub fn description(self) -> MaterialResult<Option<&'m str>> {
optional_text(
"IFCMATERIAL",
self.id(),
self.entity(),
self.slot("Description")?,
"Description",
)
}
pub fn category(self) -> MaterialResult<Option<&'m str>> {
optional_text(
"IFCMATERIAL",
self.id(),
self.entity(),
self.slot("Category")?,
"Category",
)
}
}
impl<'m> MaterialView<'m> {
pub fn materials(self) -> impl Iterator<Item = Material<'m>> + 'm {
let release = self.release();
self.model()
.of_type("IFCMATERIAL")
.map(move |(id, entity)| Material::from_known(id, entity, release))
}
}