tailscale / tailscale/tailscale-rs
ts_hexdump: move hexdump facilities to combinators rather than hand-rolled iterators
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 61
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 22
Description
Follow-on from tailscale/tailscale-rs-old#23.
It's probably smarter/more efficient to use chained combinators to perform hexdumps instead of the current hand-rolled HexdumpIter iterator; something like:
pub type HexdumpLine = heapless::String<MAX_HEXDUMP_LINE_CHARS>;
pub fn hexdump<'a>(bytes: impl Iterator<Item = &'a u8>) -> impl Iterator<Item = HexdumpLine> {
bytes
.chunks(MAX_HEXDUMP_LINE_CHARS)
.map(|line_bs| {
let mut line = HexdumpLine::new();
let (start, end) = line_bs.split_at(8);
for b in start {
write!(line, "{b:x} ").unwrap();
}
write!(line, " ").unwrap();
for b in end {
write!(line, "{b:x} ").unwrap();
}
// write ascii table
for b in line_bs {
line.push(get_ascii_char_for_byte(*b)).unwrap();
}
line.push('\n');
line
})
}
@dylan-tailscale and @npry need to have a discussion about this just to make sure we're aligned/understand any tradeoffs, and then implement once Dylan has his head around it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the current hand-rolled HexdumpIter implementation and inspect how the hexdump facilities produce their output. Review the proposed chained-combinator shape, then resolve the tradeoffs with the named maintainers before implementing it. Done means the hexdump facilities use combinators rather than the current iterator.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100