Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Commit 5303d4a

Browse files
author
Alex Helfet
committed
More documentation and notes in decoder.
1 parent 5435041 commit 5303d4a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/decoder.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,28 @@ use heapless::Vec as HVec;
55
use packet::{self, Packet, Instrumentation};
66
use std::io::Read;
77

8+
/// Parses ITM packets.
89
pub struct Decoder<R: Read> {
910
inner: R,
1011
}
1112

1213
impl<R: Read> Decoder<R> {
13-
// TODO: Builder pattern.
14-
14+
/// Construct a new `Decoder` that reads encoded packets from
15+
/// `inner`.
1516
pub fn new(inner: R) -> Decoder<R> {
1617
Decoder::<R> {
1718
inner: inner,
1819
}
1920
}
2021

22+
// TODO: If we need config for the Decoder, my plan is to:
23+
// * Add a Config struct with private fields that can be used with
24+
// `serde`, built with a builder pattern (`derive_builder` is
25+
// great), or built with a Default implementation.
26+
// * Add a method Decoder.with_config(inner: R, config: Config).
27+
28+
/// Read a single packet from the inner `Read`. This will block
29+
/// for input if no full packet is currently an available.
2130
pub fn read_packet(&mut self) -> Result<Packet> {
2231
let mut header = [0; 1];
2332
self.inner.read_exact(&mut header)?;

0 commit comments

Comments
 (0)