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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//! Typed failures for bounded IFC4 constraint semantics.
use ifc_model::EntityId;
use ifc_schema::SchemaVersion;
use thiserror::Error;
/// Constraint projection or authoring failure.
#[derive(Debug, Clone, PartialEq, Error)]
#[non_exhaustive]
pub enum ConstraintError {
/// Entity kind differs from the requested projection.
#[error("expected {expected}, found {actual}")]
WrongEntityType {
/// Expected IFC entity.
expected: &'static str,
/// Actual IFC entity.
actual: String,
},
/// Required positional attribute is absent or null.
#[error("{entity} {id} is missing {attribute}")]
MissingAttribute {
/// Entity kind.
entity: &'static str,
/// Entity identifier.
id: EntityId,
/// Attribute name.
attribute: &'static str,
},
/// Attribute has the wrong value shape or cardinality.
#[error("{entity} {id}.{attribute} is invalid: {value}")]
InvalidValue {
/// Entity kind.
entity: &'static str,
/// Entity identifier.
id: EntityId,
/// Attribute name.
attribute: &'static str,
/// Diagnostic value.
value: String,
},
/// Requested entity is absent.
#[error("entity {id} does not exist")]
UnknownEntity {
/// Missing identifier.
id: EntityId,
},
/// Authored or projected reference does not resolve.
#[error("{entity} {id}.{attribute} reference {target} does not resolve")]
DanglingReference {
/// Relationship or record kind.
entity: &'static str,
/// Owning entity identifier.
id: EntityId,
/// Attribute name.
attribute: &'static str,
/// Missing target.
target: EntityId,
},
/// Resolved reference is outside the declared IFC SELECT/type.
#[error("{entity} {id}.{attribute} target {target} has {actual}, expected {expected}")]
ReferenceType {
/// Relationship or record kind.
entity: &'static str,
/// Owning entity identifier.
id: EntityId,
/// Attribute name.
attribute: &'static str,
/// Referenced target.
target: EntityId,
/// Expected entity or SELECT.
expected: &'static str,
/// Actual entity kind.
actual: String,
},
/// Declared WHERE-style rule failed.
#[error("{entity} {id} violates {rule}: {detail}")]
Semantic {
/// Entity kind.
entity: &'static str,
/// Entity identifier.
id: EntityId,
/// Bounded rule name.
rule: &'static str,
/// Human-readable detail.
detail: String,
},
/// Draft value is invalid before staging.
#[error("cannot author {entity}.{attribute}: {value}")]
AuthoringInvalid {
/// Entity kind.
entity: &'static str,
/// Attribute or rule.
attribute: &'static str,
/// Rejected value.
value: String,
},
/// Draft reference is outside the required entity/SELECT.
#[error("authoring target {target} has {actual}, expected {expected}")]
AuthoringReferenceType {
/// Referenced target.
target: EntityId,
/// Expected entity or SELECT.
expected: &'static str,
/// Actual entity kind.
actual: String,
},
/// The model's header declares several schemas; authoring binds to
/// exactly one release.
#[error("the header declares {schemas} schemas; authoring binds to exactly one")]
MultipleSchemas {
/// Number of `FILE_SCHEMA` declarations.
schemas: usize,
},
/// The model's header declares one schema this crate is not verified
/// against (anything but IFC2X3, IFC4 and IFC4X3), so no layout can be
/// trusted. Never read or written as another release.
#[error("the header declares {schema}, which this crate is not verified against")]
UnsupportedSchema {
/// The `FILE_SCHEMA` token as written.
schema: String,
},
/// An accessor asked for an attribute the model's release does not
/// declare, such as `ReferencePath` on an IFC2X3 `IfcMetric`. Never read
/// from the slot another release gives it (#212).
#[error("{entity} {id}.{attribute} is not defined by {schema:?}")]
NotInSchema {
/// Entity kind.
entity: &'static str,
/// Entity identifier.
id: EntityId,
/// The attribute.
attribute: &'static str,
/// The release the model is read against.
schema: SchemaVersion,
},
/// A text accessor met an attribute the release types as an entity
/// record, such as the IFC2X3 `IfcConstraint.CreationTime`, an
/// `IfcDateTimeSelect`. The value is valid; read it through `target`.
#[error("{entity} {id}.{attribute} is the record {target}, not text")]
StructuredValue {
/// Entity kind.
entity: &'static str,
/// Entity identifier.
id: EntityId,
/// The attribute.
attribute: &'static str,
/// The entity record holding the value.
target: EntityId,
},
/// The model's release does not declare this entity, such as
/// `IfcResourceConstraintRelationship` or `IfcReference` in IFC2X3.
#[error("{entity} is not an instantiable entity of {schema:?}")]
EntityNotInSchema {
/// The entity type.
entity: &'static str,
/// The release the model declares.
schema: SchemaVersion,
},
/// A draft supplied a value for an attribute the model's release does
/// not declare, such as a `ReferencePath` for an IFC2X3 `IfcMetric`. It
/// is refused rather than dropped.
#[error("cannot author {entity}.{attribute}: not defined by {schema:?}")]
AuthoringNotInSchema {
/// The entity type being authored.
entity: &'static str,
/// The attribute.
attribute: &'static str,
/// The release the model declares.
schema: SchemaVersion,
},
/// A draft supplied a value in a form the release's declaration cannot
/// hold, such as text where IFC2X3 declares an `IfcDateTimeSelect`
/// record, a token its enumeration lacks, or several benchmark values
/// where IFC2X3 declares one `IfcMetric`.
#[error("cannot author {entity}.{attribute}: {schema:?} declares {declared}")]
AuthoringValueType {
/// The entity type being authored.
entity: &'static str,
/// The attribute.
attribute: &'static str,
/// The type the release declares.
declared: &'static str,
/// The release the model declares.
schema: SchemaVersion,
},
/// The model's release requires an attribute the authoring call leaves
/// unset, such as the IFC2X3 `IfcRoot.OwnerHistory`, the IFC2X3
/// `IfcRelAssociatesConstraint.Intent` or the IFC2X3 `IfcMetric.DataValue`.
#[error("cannot author {entity}: {schema:?} requires {attribute}")]
AuthoringRequired {
/// The entity type being authored.
entity: &'static str,
/// The required attribute, as the release names it.
attribute: &'static str,
/// The release the model declares.
schema: SchemaVersion,
},
}
/// Result alias for constraint operations.
pub type ConstraintResult<T> = Result<T, ConstraintError>;