1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//! The release a read binds to.
//!
//! Every accessor in this crate — `systems`, `zones`, `ports`, `flow::of`,
//! `connectivity::build` — must interpret entities against the IFC release
//! the file actually declares, not against a hard-wired one (issue #52).
//! `IfcZone` is a subtype of `IfcSystem` in IFC4 but of `IfcGroup` in
//! IFC2X3; reading an IFC2X3 file under the IFC4 table therefore
//! misclassifies zones as systems and vice versa for `IfcElectricalCircuit`.
//!
//! This module resolves that release once per read and hands out a small
//! [`Release`] carrying both the version tag (for error reporting) and the
//! bundled [`Schema`] table (for `is_a`/`attributes` lookups), mirroring the
//! pattern `ifc-properties::exact::release` established for issue #48.
use Model;
use ;
use crateSchemaResolutionError;
/// The release a read runs against: its version tag and bundled table.
///
/// Crate-private: callers get a [`SchemaVersion`] from [`schema_of`] and
/// the crate's public accessors resolve their own `Release` internally, so
/// this type never needs to appear in a public signature.
pub
/// Releases whose zone semantics are verified against their own tables:
/// `IfcZone`, `IfcRelAssignsToGroup` and the WR1 member types (#194).
const ZONE_RELEASES: & = &;
/// Releases verified for the system, port, flow and connectivity readers.
/// IFC4X3's distribution semantics (`IfcBuiltSystem`, the IFC4X3
/// distribution-system enumeration) are not verified yet.
const SYSTEM_RELEASES: & = &;
/// Resolve the IFC release a model declares, from its `FILE_SCHEMA` header.
///
/// This is the public seam issue #52 asks every read path to go through:
/// callers who want to know (or assert) which release a model will be read
/// under -- without pulling in `ifc-schema` themselves -- can call this
/// directly. It refuses a file with no schema, more than one, or a release
/// this crate has not verified for its system, port and flow readers
/// (including IFC4X3). The zone readers ([`crate::zones`],
/// [`crate::try_zones`], [`crate::long_name_of`]) are verified for IFC4X3
/// and bind its table (#194); this function still refuses it.
///
/// The crate's bulk accessors (`systems`, `zones`, `ports`,
/// `ElementRole::of`, `ConnectionGraph::build`, ...) do NOT surface that
/// refusal: their signatures have no error slot, so where this function
/// would refuse they read the model under the IFC4 table instead. A caller
/// who needs the refusal calls this first and acts on its `Err`.
///
/// # Errors
///
/// Returns [`SchemaResolutionError`] when the header names zero or more
/// than one schema, or names a schema other than IFC2X3 or IFC4.
/// Internal resolution: version tag plus the bundled table to read against.
///
/// IFC4X3 is bundled in ifc-schema, but the system, port, flow and
/// connectivity reads have only been verified against IFC2X3 and IFC4
/// semantics (#52 scope); it stays refused here until that verification
/// happens. Zones resolve through [`resolve_zones`] instead.
pub
/// [`resolve`] for the zone readers, which are verified for IFC4X3 too.
pub
/// The IFC4 table, which the bulk readers fall back to.
pub
/// Resolve the declared release for the crate's bulk accessors
/// (`systems`, `zones`, `ports`, `ElementRole::of`, `ConnectionGraph::build`).
///
/// These functions predate #52 and return `(Vec<_>, Vec<SystemAnomaly>)`,
/// not a `Result`: there is no return-type slot to carry a hard refusal
/// without a breaking signature change. So when [`resolve`] cannot bind a
/// release -- the header names no schema, several, or one this crate has
/// not verified (including IFC4X3) -- they fall back to the IFC4 table,
/// exactly as every one of them was hard-wired to do before this change.
/// This keeps every existing caller's behaviour identical for models that
/// never carried a `FILE_SCHEMA` header at all (every hand-built fixture in
/// this crate's own test suite included) while a file that DOES declare
/// IFC2X3 is now read correctly under IFC2X3 semantics.
///
/// A caller who needs a hard refusal instead of this fallback should call
/// [`schema_of`] first and act on its `Err`.
pub
/// [`resolve_or_ifc4`] for `zones()`: an IFC4X3 header binds the IFC4X3
/// table; a header binding nothing falls back to IFC4 as before.
pub