Skip to main content

powerio_core/
codes.rs

1//! Diagnostic identities emitted by the foundation crate.
2
3crate::diagnostic_codes! {
4    REQUEST_DIAGNOSTIC_INVALID_CODE = "REQUEST.DIAGNOSTIC.INVALID_CODE", Error,
5        "a diagnostic code does not match the stable code grammar", category = Request;
6    REQUEST_DIAGNOSTIC_MISSING_CATEGORY = "REQUEST.DIAGNOSTIC.MISSING_CATEGORY", Error,
7        "an error was constructed from a registry entry without an error category", category = Request;
8    REQUEST_RECORD_INVALID_IDENTIFIER = "REQUEST.RECORD.INVALID_IDENTIFIER", Error,
9        "a common record identifier is empty, contains NUL, or exceeds its bound", category = Request;
10    REQUEST_RECORD_INVALID_POINTER = "REQUEST.RECORD.INVALID_POINTER", Error,
11        "a source map or diagnostic target is not an RFC 6901 pointer", category = Request;
12    REQUEST_RECORD_INVALID_DIGEST = "REQUEST.RECORD.INVALID_DIGEST", Error,
13        "a source digest is not valid for its declared algorithm", category = Request;
14    REQUEST_RECORD_INVALID_SPAN = "REQUEST.RECORD.INVALID_SPAN", Error,
15        "a source span is reversed or outside its declared source", category = Request;
16    REQUEST_RECORD_DUPLICATE_ID = "REQUEST.RECORD.DUPLICATE_ID", Error,
17        "a module record repeats an existing local identity", category = Request;
18    REQUEST_RECORD_INVALID_EXTENSION = "REQUEST.RECORD.INVALID_EXTENSION", Error,
19        "an extension key is not namespaced", category = Request;
20    REQUEST_RECORD_TOO_LARGE = "REQUEST.RECORD.TOO_LARGE", Error,
21        "a stored record exceeds a bound the constructors enforce", category = Request;
22    REQUEST_RECORD_ALLOCATION_REFUSED = "REQUEST.RECORD.ALLOCATION_REFUSED", Error,
23        "the record identity index cannot reserve memory for the stated count", category = Request;
24
25    REQUEST_FORMAT_INVALID_ID = "REQUEST.FORMAT.INVALID_ID", Error,
26        "a format identifier does not match the stable format grammar", category = Request;
27
28    VALIDATE_COMPONENT_INVALID_ID = "VALIDATE.COMPONENT.INVALID_ID", Error,
29        "a component identity has an empty, NUL containing, or oversized part", category = Data;
30
31    REQUEST_SOURCE_INVALID_NAME = "REQUEST.SOURCE.INVALID_NAME", Error,
32        "an in-memory source name is empty, contains NUL, or exceeds its bound", category = Request;
33    REQUEST_SOURCE_INVALID_PATH = "REQUEST.SOURCE.INVALID_PATH", Error,
34        "a source path is empty or does not name a regular file or directory", category = Request;
35    REQUEST_SOURCE_SYMLINK_REFUSED = "REQUEST.SOURCE.SYMLINK_REFUSED", Error,
36        "source acquisition refused a symbolic link", category = Request;
37    REQUEST_SOURCE_NOT_A_FILE = "REQUEST.SOURCE.NOT_A_FILE", Error,
38        "source acquisition refused an entry that is not a regular file", category = Request;
39    REQUEST_SOURCE_DIRECTORY_REQUIRED = "REQUEST.SOURCE.DIRECTORY_REQUIRED", Error,
40        "a named child buffer was requested from a single-buffer source", category = Request;
41    REQUEST_SOURCE_ESCAPES_ROOT = "REQUEST.SOURCE.ESCAPES_ROOT", Error,
42        "a referenced file resolves outside the acquisition root", category = Request;
43    REQUEST_SOURCE_UNKNOWN_BUFFER = "REQUEST.SOURCE.UNKNOWN_BUFFER", Error,
44        "a referenced buffer was not supplied to an in-memory source", category = Request;
45
46    READ_IO_METADATA = "READ.IO.METADATA", Error,
47        "source metadata could not be read", category = Io;
48    READ_IO_OPEN = "READ.IO.OPEN", Error,
49        "a source buffer could not be opened", category = Io;
50    READ_IO_READ = "READ.IO.READ", Error,
51        "a source buffer could not be read completely", category = Io;
52    READ_IO_SOURCE_CHANGED = "READ.IO.SOURCE_CHANGED", Error,
53        "a source buffer changed while it was being acquired", category = Io;
54    READ_IO_ALLOCATION_REFUSED = "READ.IO.ALLOCATION_REFUSED", Error,
55        "memory for a source buffer could not be reserved", category = Io;
56    REQUEST_SOURCE_INVALID_LIMIT = "REQUEST.SOURCE.INVALID_LIMIT", Error,
57        "the primary source byte limit is invalid", category = Request;
58    READ_IO_PRIMARY_BUDGET = "READ.IO.PRIMARY_BUDGET", Error,
59        "a primary source exceeds its byte limit", category = Io;
60    READ_IO_REFERENCE_BUDGET = "READ.IO.REFERENCE_BUDGET", Error,
61        "acquiring another referenced file would pass the source acquisition budget", category = Io;
62
63    VALIDATE_TIME_POINT_INVALID_LABEL = "VALIDATE.TIME_POINT.INVALID_LABEL", Error,
64        "a time point label is empty, contains NUL, or exceeds its bound", category = Data;
65    VALIDATE_TIME_POINT_INVALID_DURATION = "VALIDATE.TIME_POINT.INVALID_DURATION", Error,
66        "a time point duration has an invalid nanosecond remainder", category = Data;
67    VALIDATE_TIME_SERIES_SHAPE = "VALIDATE.TIME_SERIES.SHAPE", Error,
68        "time point and value counts differ", category = Data;
69
70    VALIDATE_SCENARIO_INVALID_ID = "VALIDATE.SCENARIO.INVALID_ID", Error,
71        "a scenario identity is empty, contains NUL, or exceeds its bound", category = Data;
72    VALIDATE_SCENARIO_DUPLICATE_ID = "VALIDATE.SCENARIO.DUPLICATE_ID", Error,
73        "a scenario set repeats a case-sensitive scenario identity", category = Data;
74    VALIDATE_SCENARIO_MISSING_PROBABILITY = "VALIDATE.SCENARIO.MISSING_PROBABILITY", Error,
75        "a scenario set supplies probabilities for only some entries", category = Data;
76    VALIDATE_SCENARIO_INVALID_PROBABILITY = "VALIDATE.SCENARIO.INVALID_PROBABILITY", Error,
77        "a scenario probability is negative or nonfinite", category = Data;
78    VALIDATE_SCENARIO_PROBABILITY_SUM = "VALIDATE.SCENARIO.PROBABILITY_SUM", Error,
79        "scenario probabilities do not sum to one within the required tolerance", category = Data;
80    VALIDATE_SCENARIO_ALLOCATION_REFUSED = "VALIDATE.SCENARIO.ALLOCATION_REFUSED", Error,
81        "memory for scenario identity validation could not be reserved", category = Data;
82
83    REQUEST_OUTPUT_INVALID_ARTIFACT_PATH = "REQUEST.OUTPUT.INVALID_ARTIFACT_PATH", Error,
84        "an artifact path is not a portable nonempty relative path", category = Request;
85    REQUEST_OUTPUT_INVALID_LAYOUT = "REQUEST.OUTPUT.INVALID_LAYOUT", Error,
86        "an artifact inventory does not match the requested output layout", category = Request;
87    REQUEST_OUTPUT_DUPLICATE_ARTIFACT = "REQUEST.OUTPUT.DUPLICATE_ARTIFACT", Error,
88        "an artifact inventory repeats a path", category = Request;
89    REQUEST_OUTPUT_COLLISION = "REQUEST.OUTPUT.COLLISION", Error,
90        "an output target already exists", category = Request;
91    EMIT_IO_STAGING = "EMIT.IO.STAGING", Error,
92        "a sibling output staging path could not be created", category = Io;
93    EMIT_IO_WRITE = "EMIT.IO.WRITE", Error,
94        "an output artifact could not be written", category = Io;
95    EMIT_IO_COMMIT = "EMIT.IO.COMMIT", Error,
96        "a complete staged output could not be moved into place", category = Io;
97    EMIT_IO_CLEANUP = "EMIT.IO.CLEANUP", Error,
98        "an incomplete output staging path could not be removed", category = Io;
99}
100
101pub use ALL as CORE_DIAGNOSTIC_CODES;
102
103#[cfg(test)]
104mod tests {
105    #[test]
106    fn core_registry_is_valid() {
107        assert_eq!(
108            crate::check_registry(super::ALL.iter().copied()),
109            Vec::<String>::new()
110        );
111    }
112}