Skip to content

Commit

Permalink
mqtt: add notes
Browse files Browse the repository at this point in the history
  • Loading branch information
jordens committed Nov 21, 2024
1 parent 9056ada commit 5cf3a73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion miniconf/src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl<M: TreeKey + ?Sized, N, const D: usize> NodeIter<M, N, D> {
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 {}",
Expand Down
18 changes: 10 additions & 8 deletions miniconf_mqtt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ where
config: ConfigBuilder<'a, Broker>,
) -> Result<Self, ProtocolError> {
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);

Expand Down Expand Up @@ -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()
});
Expand Down

0 comments on commit 5cf3a73

Please sign in to comment.