tailscale / tailscale/tailscale-rs

ts_hexdump: move hexdump facilities to combinators rather than hand-rolled iterators

Open
#19 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement tech debt
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.