From 5cf3a73c2f4d07187c46f5e4af1a8065d480cde6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Fri, 22 Nov 2024 00:14:31 +0100 Subject: [PATCH] mqtt: add notes --- miniconf/src/iter.rs | 2 +- miniconf_mqtt/src/lib.rs | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/miniconf/src/iter.rs b/miniconf/src/iter.rs index 0f7bbb78..4d4093a1 100644 --- a/miniconf/src/iter.rs +++ b/miniconf/src/iter.rs @@ -125,7 +125,7 @@ impl NodeIter { assert_eq!(self.depth, D + 1, "NodeIter partially consumed"); assert_eq!(self.root, 0, "NodeIter on sub-tree"); debug_assert_eq!(&self.state, &[0; D]); // ensured by depth = D + 1 marker and contract - let meta: Metadata = M::traverse_all().unwrap(); + let meta: Metadata = M::traverse_all().unwrap(); // Note(unwrap): infallible assert!( D >= meta.max_depth, "depth D = {D} must be at least {}", diff --git a/miniconf_mqtt/src/lib.rs b/miniconf_mqtt/src/lib.rs index f61fafce..c3149262 100644 --- a/miniconf_mqtt/src/lib.rs +++ b/miniconf_mqtt/src/lib.rs @@ -251,7 +251,7 @@ where config: ConfigBuilder<'a, Broker>, ) -> Result { assert_eq!("/".len(), SEPARATOR.len_utf8()); - let meta: Metadata = Settings::traverse_all().unwrap(); + let meta: Metadata = Settings::traverse_all().unwrap(); // Note(unwrap): infallible assert!(meta.max_depth <= Y); assert!(prefix.len() + "/settings".len() + meta.max_length("/") <= MAX_TOPIC_LENGTH); @@ -529,13 +529,15 @@ where // Internal node: Dump or List (state.state() != &sm::States::Single) .then_some("Pending multipart response") - .or_else(|| Multipart::try_from(properties) - .map(|m| { - *pending = m.root(path).unwrap(); // Note(unwrap) checked that it's TooShort but valid leaf - state.process_event(sm::Events::Multipart).unwrap(); - // Responses come through iter_list/iter_dump - }) - .err()) + .or_else(|| { + Multipart::try_from(properties) + .map(|m| { + *pending = m.root(path).unwrap(); // Note(unwrap) checked that it's TooShort but valid leaf + state.process_event(sm::Events::Multipart).unwrap(); + // Responses come through iter_list/iter_dump + }) + .err() + }) .map(|msg| { Self::respond(msg, ResponseCode::Error, properties, client).ok() });