refactor(firmware): simplify configuration and diagnostics
This commit is contained in:
1 parent
ba9c97ed3b
commit
fdf82a5114
96 files changed
+1612
-2772
No files matched your search
@@ -16,7 +16,7 @@
|
||||
//! field IDs and therefore also accepts a complete, uniquely identified set in
|
||||
//! another order.
|
||||
|
||||
use kaptan_log::KaptanError;
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
|
||||
use crate::{ConfigModel, ConfigValue, FieldId, FieldWriteError, ValueKind};
|
||||
|
||||
@@ -48,14 +48,19 @@ pub const fn scalar_snapshot_length(field_count: u16) -> usize {
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, KaptanError)]
|
||||
pub enum SnapshotModelError {
|
||||
/// `field_count` includes an index with no descriptor.
|
||||
#[kaptan_error(id = 1501)]
|
||||
MissingDescriptor(u16),
|
||||
/// A descriptor exists at the first index after `field_count`.
|
||||
#[kaptan_error(id = 1502)]
|
||||
ExtraDescriptor(u16),
|
||||
/// Two descriptor indexes expose the same stable field identity.
|
||||
#[kaptan_error(id = 1503)]
|
||||
DuplicateDescriptor(FieldId),
|
||||
/// A descriptor has no readable value in the supplied candidate.
|
||||
#[kaptan_error(id = 1504)]
|
||||
MissingValue(FieldId),
|
||||
/// A candidate returned a scalar type different from its descriptor.
|
||||
#[kaptan_error(id = 1505)]
|
||||
WrongValueKind {
|
||||
/// Descriptor identity.
|
||||
field: FieldId,
|
||||
@@ -70,6 +75,7 @@ pub enum SnapshotModelError {
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, KaptanError)]
|
||||
pub enum ScalarSnapshotEncodeError {
|
||||
/// The destination cannot hold the complete canonical payload.
|
||||
#[kaptan_error(id = 1601)]
|
||||
BufferTooSmall {
|
||||
/// Exact number of bytes required.
|
||||
required: usize,
|
||||
@@ -77,6 +83,7 @@ pub enum ScalarSnapshotEncodeError {
|
||||
available: usize,
|
||||
},
|
||||
/// The model's descriptor/value contract is internally inconsistent.
|
||||
#[kaptan_error(id = 1602)]
|
||||
InvalidModel(SnapshotModelError),
|
||||
}
|
||||
|
||||
@@ -84,6 +91,7 @@ pub enum ScalarSnapshotEncodeError {
|
||||
#[derive(Clone, Copy, Debug, PartialEq, KaptanError)]
|
||||
pub enum ScalarSnapshotDecodeError {
|
||||
/// The input ends before the complete header or declared field set.
|
||||
#[kaptan_error(id = 1701)]
|
||||
Truncated {
|
||||
/// Exact number of bytes required once it is known.
|
||||
required: usize,
|
||||
@@ -91,6 +99,7 @@ pub enum ScalarSnapshotDecodeError {
|
||||
available: usize,
|
||||
},
|
||||
/// Bytes remain after the exact declared field set.
|
||||
#[kaptan_error(id = 1702)]
|
||||
TrailingData {
|
||||
/// Exact number of bytes required.
|
||||
expected: usize,
|
||||
@@ -98,10 +107,13 @@ pub enum ScalarSnapshotDecodeError {
|
||||
actual: usize,
|
||||
},
|
||||
/// The payload does not carry the scalar-snapshot magic.
|
||||
#[kaptan_error(id = 1703)]
|
||||
InvalidMagic,
|
||||
/// The payload uses an unsupported scalar-snapshot format.
|
||||
#[kaptan_error(id = 1704)]
|
||||
UnsupportedVersion(u8),
|
||||
/// The payload belongs to another configuration schema.
|
||||
#[kaptan_error(id = 1705)]
|
||||
WrongSchema {
|
||||
/// Schema compiled into the target model.
|
||||
expected: [u8; 16],
|
||||
@@ -109,6 +121,7 @@ pub enum ScalarSnapshotDecodeError {
|
||||
actual: [u8; 16],
|
||||
},
|
||||
/// The payload is not a complete snapshot for this schema.
|
||||
#[kaptan_error(id = 1706)]
|
||||
WrongFieldCount {
|
||||
/// Exact number of fields compiled into the target model.
|
||||
expected: u16,
|
||||
@@ -116,18 +129,25 @@ pub enum ScalarSnapshotDecodeError {
|
||||
actual: u16,
|
||||
},
|
||||
/// The target model's descriptor registry is internally inconsistent.
|
||||
#[kaptan_error(id = 1707)]
|
||||
InvalidModel(SnapshotModelError),
|
||||
/// An entry used a reserved stable field identity.
|
||||
#[kaptan_error(id = 1708)]
|
||||
InvalidFieldId(u16),
|
||||
/// An entry names no field in the target schema.
|
||||
#[kaptan_error(id = 1709)]
|
||||
UnknownField(FieldId),
|
||||
/// The complete payload identifies one field more than once.
|
||||
#[kaptan_error(id = 1710)]
|
||||
DuplicateField(FieldId),
|
||||
/// The complete payload does not identify a required schema field.
|
||||
#[kaptan_error(id = 1711)]
|
||||
MissingField(FieldId),
|
||||
/// An entry contains no supported scalar-kind discriminator.
|
||||
#[kaptan_error(id = 1712)]
|
||||
InvalidValueKind(u8),
|
||||
/// An entry's scalar kind differs from the target descriptor.
|
||||
#[kaptan_error(id = 1713)]
|
||||
WrongValueKind {
|
||||
/// Entry identity.
|
||||
field: FieldId,
|
||||
@@ -137,6 +157,7 @@ pub enum ScalarSnapshotDecodeError {
|
||||
actual: ValueKind,
|
||||
},
|
||||
/// Scalar bits are not canonical for the entry's declared kind.
|
||||
#[kaptan_error(id = 1714)]
|
||||
InvalidValueBits {
|
||||
/// Entry identity.
|
||||
field: FieldId,
|
||||
@@ -144,6 +165,7 @@ pub enum ScalarSnapshotDecodeError {
|
||||
kind: ValueKind,
|
||||
},
|
||||
/// The model rejected an otherwise structurally valid scalar write.
|
||||
#[kaptan_error(id = 1715)]
|
||||
InvalidWrite(FieldWriteError),
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user