feat(mavlink): adopt the kaptan-native dialect
This commit is contained in:
1 parent
1c90870634
commit
5f91465e66
87 files changed
+7733
-6850
No files matched your search
@@ -173,6 +173,8 @@ where
|
||||
{
|
||||
match value {
|
||||
ConfigValue::Bool(value) => encoder.bool(value)?,
|
||||
ConfigValue::U8(value) => encoder.u8(value)?,
|
||||
ConfigValue::U16(value) => encoder.u16(value)?,
|
||||
ConfigValue::I32(value) => encoder.i32(value)?,
|
||||
ConfigValue::U32(value) => encoder.u32(value)?,
|
||||
ConfigValue::U64(value) => encoder.u64(value)?,
|
||||
@@ -185,6 +187,8 @@ where
|
||||
fn decode_value(decoder: &mut Decoder<'_>, kind: ValueKind) -> Result<ConfigValue, CborError> {
|
||||
match kind {
|
||||
ValueKind::Bool => decoder.bool().map(ConfigValue::Bool),
|
||||
ValueKind::U8 => decoder.u8().map(ConfigValue::U8),
|
||||
ValueKind::U16 => decoder.u16().map(ConfigValue::U16),
|
||||
ValueKind::I32 => decoder.i32().map(ConfigValue::I32),
|
||||
ValueKind::U32 => decoder.u32().map(ConfigValue::U32),
|
||||
ValueKind::U64 => decoder.u64().map(ConfigValue::U64),
|
||||
@@ -224,7 +228,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn encoding_rejects_a_cross_field_invalid_transaction_before_writing() {
|
||||
fn encoding_rejects_a_cross_field_invalid_candidate_before_writing() {
|
||||
let capabilities = VehicleCapabilities::quad_x();
|
||||
let mut candidate = CandidateProfile::factory();
|
||||
candidate
|
||||
|
||||
@@ -229,7 +229,7 @@ impl ConfigModel for CandidateProfile {
|
||||
}
|
||||
|
||||
fn field_count() -> u16 {
|
||||
u16::try_from(Self::FIELD_COUNT).expect("field registry exceeds the protocol limit")
|
||||
u16::try_from(Self::FIELD_COUNT).expect("field registry exceeds the artifact limit")
|
||||
}
|
||||
|
||||
fn field_value(&self, id: FieldId) -> Option<ConfigValue> {
|
||||
@@ -263,8 +263,8 @@ mod tests {
|
||||
assert_eq!(
|
||||
crate::SCHEMA_ID,
|
||||
[
|
||||
0xa1, 0x4c, 0x28, 0xba, 0x08, 0xc0, 0xfd, 0xc3, 0xe2, 0x54, 0x7d, 0x77, 0x40, 0x3c,
|
||||
0xed, 0x94,
|
||||
0xb9, 0x8b, 0xf9, 0xa0, 0x62, 0x3f, 0x6e, 0xef, 0x4e, 0x88, 0xc6, 0xd8, 0x89, 0x4c,
|
||||
0x76, 0x8b,
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -355,7 +355,7 @@ mod tests {
|
||||
candidate
|
||||
.set_field(
|
||||
descriptor_id("mavlink.logging.level_filter"),
|
||||
ConfigValue::U32(LevelFilter::Off.wire_value().into()),
|
||||
ConfigValue::U8(LevelFilter::Off.wire_value()),
|
||||
)
|
||||
.unwrap();
|
||||
let active = candidate.validate(&CAPABILITIES).unwrap();
|
||||
@@ -363,7 +363,7 @@ mod tests {
|
||||
candidate
|
||||
.set_field(
|
||||
descriptor_id("mavlink.logging.level_filter"),
|
||||
ConfigValue::U32(LevelFilter::Trace.wire_value().into()),
|
||||
ConfigValue::U8(LevelFilter::Trace.wire_value()),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
@@ -373,7 +373,7 @@ mod tests {
|
||||
assert!(matches!(
|
||||
candidate.set_field(
|
||||
descriptor_id("mavlink.logging.level_filter"),
|
||||
ConfigValue::U32(6),
|
||||
ConfigValue::U8(6),
|
||||
),
|
||||
Err(FieldWriteError::Violation(issue))
|
||||
if issue.rule() == ValidationRule::InvalidEnumValue
|
||||
@@ -387,7 +387,7 @@ mod tests {
|
||||
candidate
|
||||
.set_field(
|
||||
descriptor_id("mavlink.logging.level_filter"),
|
||||
ConfigValue::U32(raw),
|
||||
ConfigValue::U8(raw),
|
||||
)
|
||||
.expect("descriptor accepts the stable level filter");
|
||||
assert_eq!(
|
||||
@@ -395,7 +395,7 @@ mod tests {
|
||||
.validate(&CAPABILITIES)
|
||||
.expect("valid complete profile")
|
||||
.mavlink_logging(),
|
||||
LevelFilter::try_from_wire(u8::try_from(raw).unwrap()).unwrap()
|
||||
LevelFilter::try_from_wire(raw).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user