Skip to content

Commit

Permalink
fix: use parser to parse information elements
Browse files Browse the repository at this point in the history
Information elements can be parsed using `InformationElements::parse`.
  • Loading branch information
thvdveld committed Feb 27, 2024
1 parent 078bc77 commit 98f6e03
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions dot15d4/src/frame/repr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,9 @@ impl<'f> FrameRepr<'f> {
reader.addressing(),
reader.frame_control(),
),
information_elements: reader.information_elements().map(|ie| {
let mut header_information_elements = Vec::new();
let mut payload_information_elements = Vec::new();

for header_ie in ie.header_information_elements() {
header_information_elements
.push(HeaderInformationElementRepr::parse(header_ie));
}

for payload_ie in ie.payload_information_elements() {
payload_information_elements
.push(PayloadInformationElementRepr::parse(payload_ie));
}

InformationElementsRepr {
header_information_elements,
payload_information_elements,
}
}),
information_elements: reader
.information_elements()
.map(InformationElementsRepr::parse),
payload: reader.payload().unwrap_or(&[]),
}
}
Expand Down

0 comments on commit 98f6e03

Please sign in to comment.