ifc_tabular/read/issue.rs
1//! What a read found wrong with a table or time series.
2
3use ifc_model::EntityId;
4
5/// One defect found while reading a table or time series.
6///
7/// A read never drops what it cannot decode: a malformed slot, a dangling
8/// reference, or a violated WHERE rule becomes an issue on the returned
9/// view, and whatever did decode is still returned beside it. `entity` is
10/// always the record the defect sits on, which may be a row, column or
11/// value record rather than the container that was asked for.
12#[derive(Debug, Clone, PartialEq, Eq)]
13#[non_exhaustive]
14pub enum TabularIssue {
15 /// The record's slot count differs from its schema declaration.
16 ///
17 /// Slots are still read by position, so a short record reports its
18 /// missing required attributes as well.
19 Arity {
20 /// The record.
21 entity: EntityId,
22 /// Its STEP type name.
23 type_name: &'static str,
24 /// Slots the schema declares.
25 expected: usize,
26 /// Slots the record carries.
27 found: usize,
28 },
29 /// A required attribute is null or absent.
30 Missing {
31 /// The record.
32 entity: EntityId,
33 /// The attribute.
34 attribute: &'static str,
35 },
36 /// A slot holds a value its declaration does not admit.
37 Malformed {
38 /// The record.
39 entity: EntityId,
40 /// The attribute.
41 attribute: &'static str,
42 /// The value found, in `Debug` form.
43 found: String,
44 },
45 /// A `LIST [1:?]` attribute is present but empty.
46 EmptyList {
47 /// The record.
48 entity: EntityId,
49 /// The attribute.
50 attribute: &'static str,
51 },
52 /// A reference names a record the model does not hold.
53 Dangling {
54 /// The record holding the reference.
55 entity: EntityId,
56 /// The attribute.
57 attribute: &'static str,
58 /// The missing target.
59 target: EntityId,
60 },
61 /// A reference names a record of the wrong type.
62 WrongReferenceType {
63 /// The record holding the reference.
64 entity: EntityId,
65 /// The attribute.
66 attribute: &'static str,
67 /// The target.
68 target: EntityId,
69 /// The type the declaration requires.
70 expected: &'static str,
71 /// The type the target has.
72 actual: String,
73 },
74 /// `IfcTable.WR1`: a row's cell count differs from the first row's.
75 RaggedRow {
76 /// The table.
77 table: EntityId,
78 /// The offending row.
79 row: EntityId,
80 /// Its zero-based position in `Rows`.
81 index: usize,
82 /// Cells in `Rows[1]`.
83 expected: usize,
84 /// Cells in this row.
85 found: usize,
86 },
87 /// `IfcTable.WR2`: more than one row has `IsHeading` TRUE.
88 TooManyHeadings {
89 /// The table.
90 table: EntityId,
91 /// How many rows claim to be the heading.
92 found: usize,
93 },
94}