Skip to main content

powerio/
codes.rs

1//! The facade's diagnostic code registry. An emission site names an entry
2//! rather than a loose string.
3
4powerio_core::diagnostic_codes! {
5    REQUEST_PARSE_POWERIO_IR = "REQUEST.PARSE.POWERIO_IR", Error,
6        "PowerIO IR is decoded with deserialize, not parse", category = Request;
7    READ_MODULE_UNSUPPORTED = "READ.MODULE.UNSUPPORTED", Error,
8        "the stored module names a schema or version this build does not read", category = Request;
9    READ_MODULE_INVALID = "READ.MODULE.INVALID", Error,
10        "the stored module document is structurally invalid", category = Data;
11    VALIDATE_COLLECTION_EMPTY = "VALIDATE.COLLECTION.EMPTY", Error,
12        "a dynamically constructed collection needs at least one value to infer its type", category = Data;
13    VALIDATE_COLLECTION_ELEMENT_TYPE = "VALIDATE.COLLECTION.ELEMENT_TYPE", Error,
14        "all values in a collection must have the same supported structural type", category = Data;
15    // LOWER: the multiconductor to balanced pass.
16    TRANSFORM_MULTI_TO_BALANCED_AMBIGUOUS_TERMINAL_MAP =
17        "TRANSFORM.MULTI_TO_BALANCED.AMBIGUOUS_TERMINAL_MAP", Error,
18        "a terminal map does not determine one balanced phase assignment";
19    TRANSFORM_MULTI_TO_BALANCED_BALANCED_VALUE_DOMAIN =
20        "TRANSFORM.MULTI_TO_BALANCED.BALANCED_VALUE_DOMAIN", Warning,
21        "a lowered value is outside the domain the balanced model states";
22    TRANSFORM_MULTI_TO_BALANCED_DROPPED_LOAD_VOLTAGE_MODEL =
23        "TRANSFORM.MULTI_TO_BALANCED.DROPPED_LOAD_VOLTAGE_MODEL", Warning,
24        "a load voltage model has no balanced spelling and was dropped";
25    TRANSFORM_MULTI_TO_BALANCED_DROPPED_OPEN_SWITCH =
26        "TRANSFORM.MULTI_TO_BALANCED.DROPPED_OPEN_SWITCH", Remark,
27        "an open switch was dropped from the balanced network";
28    TRANSFORM_MULTI_TO_BALANCED_INVALID_BALANCED_OUTPUT =
29        "TRANSFORM.MULTI_TO_BALANCED.INVALID_BALANCED_OUTPUT", Error,
30        "the lowered network does not validate";
31    TRANSFORM_MULTI_TO_BALANCED_INVALID_BASE_MVA =
32        "TRANSFORM.MULTI_TO_BALANCED.INVALID_BASE_MVA", Error,
33        "the requested base MVA is not a positive finite number";
34    TRANSFORM_MULTI_TO_BALANCED_INVALID_LINECODE_MATRIX =
35        "TRANSFORM.MULTI_TO_BALANCED.INVALID_LINECODE_MATRIX", Error,
36        "a linecode matrix cannot be reduced to a balanced impedance";
37    TRANSFORM_MULTI_TO_BALANCED_INVALID_PHASE_REFERENCE =
38        "TRANSFORM.MULTI_TO_BALANCED.INVALID_PHASE_REFERENCE", Error,
39        "a phase reference names a conductor the element does not have";
40    TRANSFORM_MULTI_TO_BALANCED_INVALID_SHUNT_MATRIX =
41        "TRANSFORM.MULTI_TO_BALANCED.INVALID_SHUNT_MATRIX", Error,
42        "a shunt matrix cannot be reduced to a balanced admittance";
43    TRANSFORM_MULTI_TO_BALANCED_KRON_REDUCTION_REQUIRED =
44        "TRANSFORM.MULTI_TO_BALANCED.KRON_REDUCTION_REQUIRED", Remark,
45        "a conductor set needs a Kron reduction the pass does not perform";
46    TRANSFORM_MULTI_TO_BALANCED_LINECODE_TERMINAL_MISMATCH =
47        "TRANSFORM.MULTI_TO_BALANCED.LINECODE_TERMINAL_MISMATCH", Error,
48        "a linecode's dimension disagrees with the line's terminal map";
49    TRANSFORM_MULTI_TO_BALANCED_MISSING_PHASE_REFERENCE =
50        "TRANSFORM.MULTI_TO_BALANCED.MISSING_PHASE_REFERENCE", Error,
51        "an element states no phase reference to lower against";
52    TRANSFORM_MULTI_TO_BALANCED_NONFINITE_LINE_LENGTH =
53        "TRANSFORM.MULTI_TO_BALANCED.NONFINITE_LINE_LENGTH", Error,
54        "a line length is not finite, so its impedance is undefined";
55    TRANSFORM_MULTI_TO_BALANCED_PHASE_MAP_MISMATCH =
56        "TRANSFORM.MULTI_TO_BALANCED.PHASE_MAP_MISMATCH", Error,
57        "the two ends of an element do not agree on their phase map";
58    TRANSFORM_MULTI_TO_BALANCED_SEQUENCE_COUPLING_DROPPED =
59        "TRANSFORM.MULTI_TO_BALANCED.SEQUENCE_COUPLING_DROPPED", Remark,
60        "sequence coupling has no balanced spelling and was dropped";
61    TRANSFORM_MULTI_TO_BALANCED_UNKNOWN_BUS = "TRANSFORM.MULTI_TO_BALANCED.UNKNOWN_BUS", Error,
62        "an element references a bus the multiconductor payload does not declare";
63    TRANSFORM_MULTI_TO_BALANCED_UNKNOWN_LINECODE =
64        "TRANSFORM.MULTI_TO_BALANCED.UNKNOWN_LINECODE", Error,
65        "a line references a linecode the payload does not declare";
66    TRANSFORM_MULTI_TO_BALANCED_UNKNOWN_SOURCE_BUS =
67        "TRANSFORM.MULTI_TO_BALANCED.UNKNOWN_SOURCE_BUS", Error,
68        "a voltage source references a bus the payload does not declare";
69    TRANSFORM_MULTI_TO_BALANCED_RATED_CLOSED_SWITCH =
70        "TRANSFORM.MULTI_TO_BALANCED.RATED_CLOSED_SWITCH", Error,
71        "merging a rated closed switch would erase its flow limit";
72    TRANSFORM_MULTI_TO_BALANCED_SWITCH_TERMINAL_MISMATCH =
73        "TRANSFORM.MULTI_TO_BALANCED.SWITCH_TERMINAL_MISMATCH", Error,
74        "the two ends of a closed switch do not map identical conductors";
75    TRANSFORM_MULTI_TO_BALANCED_SWITCH_MERGE_CONFLICT =
76        "TRANSFORM.MULTI_TO_BALANCED.SWITCH_MERGE_CONFLICT", Error,
77        "the buses a closed switch would merge state conflicting data";
78    TRANSFORM_MULTI_TO_BALANCED_UNSUPPORTED_CONDUCTOR_SET =
79        "TRANSFORM.MULTI_TO_BALANCED.UNSUPPORTED_CONDUCTOR_SET", Error,
80        "a conductor set has no balanced spelling";
81    TRANSFORM_MULTI_TO_BALANCED_UNSUPPORTED_OBJECT =
82        "TRANSFORM.MULTI_TO_BALANCED.UNSUPPORTED_OBJECT", Error,
83        "an object has no balanced spelling and was dropped";
84    TRANSFORM_MULTI_TO_BALANCED_UNSUPPORTED_TRANSFORMER =
85        "TRANSFORM.MULTI_TO_BALANCED.UNSUPPORTED_TRANSFORMER", Error,
86        "a transformer shape has no balanced spelling";
87    TRANSFORM_MULTI_TO_BALANCED_RECORD_CAP =
88        "TRANSFORM.MULTI_TO_BALANCED.RECORD_CAP", Error,
89        "the lowered module's records would exceed a module maximum",
90        category = Request;
91    TRANSFORM_MULTI_TO_BALANCED_WRONG_MODEL_KIND =
92        "TRANSFORM.MULTI_TO_BALANCED.WRONG_MODEL_KIND", Error,
93        "the module does not carry a multiconductor payload to lower",
94        category = Request;
95
96    // Failures.
97    REQUEST_MODULE_WRONG_MODEL_KIND = "REQUEST.MODULE.WRONG_MODEL_KIND", Error,
98        "the call asks for a model family the document does not carry", category = Request;
99    TRANSFORM_LINDIST3FLOW_OPTIONS_SERIALIZE_FAILED =
100        "TRANSFORM.LINDIST3FLOW.OPTIONS_SERIALIZE_FAILED", Error,
101        "serializing LinDist3Flow options for transform history failed", category = Output;
102    EMIT_MODULE_SERIALIZE_FAILED = "EMIT.MODULE.SERIALIZE_FAILED", Error,
103        "serializing the stored document to JSON failed", category = Output;
104}
105
106/// Every code this crate declares.
107#[must_use]
108pub fn registry() -> Vec<&'static powerio_core::DiagnosticInfo> {
109    ALL.to_vec()
110}
111
112#[cfg(test)]
113mod tests {
114    use super::*;
115
116    #[test]
117    fn the_registry_is_sound() {
118        let problems = powerio_core::check_registry(registry());
119        assert!(problems.is_empty(), "{problems:#?}");
120    }
121}