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(
11            "IFCLIBRARYINFORMATION",
12            self.id(),
13            self.entity(),
14            self.text_slot("Name")?,
15            "Name",
16        )
17    }
18    /// The `Version` label of the library, when authored.
19    pub fn version(self) -> ClassificationResult<Option<&'m str>> {
20        optional_text(
21            "IFCLIBRARYINFORMATION",
22            self.id(),
23            self.entity(),
24            self.text_slot("Version")?,
25            "Version",
26        )
27    }
28    /// Id of the `Publisher` (an `IfcActorSelect`), when authored.
29    pub fn publisher_id(self) -> ClassificationResult<Option<ifc_model::EntityId>> {
30        optional_ref(
31            "IFCLIBRARYINFORMATION",
32            self.id(),
33            self.entity(),
34            self.slot("Publisher")?,
35            "Publisher",
36        )
37    }
38    /// The `VersionDate` of the library, when authored.
39    pub fn version_date(self) -> ClassificationResult<Option<&'m str>> {
40        optional_text(
41            "IFCLIBRARYINFORMATION",
42            self.id(),
43            self.entity(),
44            self.text_slot("VersionDate")?,
45            "VersionDate",
46        )
47    }
48    /// The `Location` (e.g. a URI) of the library, when authored.
49    pub fn location(self) -> ClassificationResult<Option<&'m str>> {
50        optional_text(
51            "IFCLIBRARYINFORMATION",
52            self.id(),
53            self.entity(),
54            self.text_slot("Location")?,
55            "Location",
56        )
57    }
58    /// The `Description` of the library, when authored.
59    pub fn description(self) -> ClassificationResult<Option<&'m str>> {
60        optional_text(
61            "IFCLIBRARYINFORMATION",
62            self.id(),
63            self.entity(),
64            self.text_slot("Description")?,
65            "Description",
66        )
67    }
68}
69impl<'m> ClassificationView<'m> {
70    /// All `IfcLibraryInformation` instances in the model.
71    pub fn libraries(self) -> impl Iterator<Item = LibraryInformation<'m>> + 'm {
72        self.model()
73            .of_type("IFCLIBRARYINFORMATION")
74            .map(move |(id, e)| LibraryInformation::from_known(id, e, self.release()))
75    }
76}