Skip to main content

ifc_classification/library/
information.rs

1//! Borrowed `IfcLibraryInformation` projection.
2use crate::view::{
3    borrowed_entity, optional_ref, optional_text, required_text, ClassificationView,
4};
5use crate::ClassificationResult;
6borrowed_entity!(LibraryInformation, "IFCLIBRARYINFORMATION");
7impl<'m> LibraryInformation<'m> {
8    /// The required `Name` of the library.
9    pub fn name(self) -> ClassificationResult<&'m str> {
10        required_text("IFCLIBRARYINFORMATION", self.id(), self.entity(), 0, "Name")
11    }
12    /// The `Version` label of the library, when authored.
13    pub fn version(self) -> ClassificationResult<Option<&'m str>> {
14        optional_text(
15            "IFCLIBRARYINFORMATION",
16            self.id(),
17            self.entity(),
18            1,
19            "Version",
20        )
21    }
22    /// Id of the `Publisher` (an `IfcActorSelect`), when authored.
23    pub fn publisher_id(self) -> ClassificationResult<Option<ifc_model::EntityId>> {
24        optional_ref(
25            "IFCLIBRARYINFORMATION",
26            self.id(),
27            self.entity(),
28            2,
29            "Publisher",
30        )
31    }
32    /// The `VersionDate` of the library, when authored.
33    pub fn version_date(self) -> ClassificationResult<Option<&'m str>> {
34        optional_text(
35            "IFCLIBRARYINFORMATION",
36            self.id(),
37            self.entity(),
38            3,
39            "VersionDate",
40        )
41    }
42    /// The `Location` (e.g. a URI) of the library, when authored.
43    pub fn location(self) -> ClassificationResult<Option<&'m str>> {
44        optional_text(
45            "IFCLIBRARYINFORMATION",
46            self.id(),
47            self.entity(),
48            4,
49            "Location",
50        )
51    }
52    /// The `Description` of the library, when authored.
53    pub fn description(self) -> ClassificationResult<Option<&'m str>> {
54        optional_text(
55            "IFCLIBRARYINFORMATION",
56            self.id(),
57            self.entity(),
58            5,
59            "Description",
60        )
61    }
62}
63impl<'m> ClassificationView<'m> {
64    /// All `IfcLibraryInformation` instances in the model.
65    pub fn libraries(self) -> impl Iterator<Item = LibraryInformation<'m>> + 'm {
66        self.model()
67            .of_type("IFCLIBRARYINFORMATION")
68            .map(|(id, e)| LibraryInformation::from_known(id, e))
69    }
70}