Skip to content

quicvarint: implement function to peek the next varint#5502

Merged
marten-seemann merged 1 commit intomasterfrom
peek-varint
Dec 29, 2025
Merged

quicvarint: implement function to peek the next varint#5502
marten-seemann merged 1 commit intomasterfrom
peek-varint

Conversation

@marten-seemann
Copy link
Copy Markdown
Member

@marten-seemann marten-seemann commented Dec 26, 2025

Peek doesn’t consume any more bytes than needed to parse the next QUIC varint.

Depends on #5501. For #4405.

@marten-seemann marten-seemann added this to the v0.59 milestone Dec 26, 2025
@macroscopeapp
Copy link
Copy Markdown

macroscopeapp Bot commented Dec 26, 2025

Add quicvarint.Peek to read the next QUIC varint without consuming bytes using a quicvarint.Peeker in io.go

Introduce quicvarint.Peeker and implement quicvarint.Peek to parse 1-, 2-, 4-, and 8-byte varints from a peeked buffer; update a doc comment in quicvarint.NewWriter. Tests cover correct parsing and io.ErrUnexpectedEOF.

📍Where to Start

Start with the quicvarint.Peek function and quicvarint.Peeker interface in io.go.


Macroscope summarized 89050f6.

Comment thread quicvarint/io.go
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a Peek function for reading QUIC varints without consuming bytes from the input. The implementation introduces a new Peeker interface and provides comprehensive test coverage for all varint sizes and error conditions.

Key Changes:

  • Added Peeker interface and Peek function to support non-consuming reads of QUIC varints
  • Implemented comprehensive tests covering all varint encodings (1, 2, 4, and 8 bytes) and error cases
  • Fixed a minor documentation typo in the NewWriter function comment

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
quicvarint/io.go Defines the Peeker interface and implements the Peek function that reads QUIC varints without consuming bytes; also fixes a documentation typo in the NewWriter comment
quicvarint/io_test.go Adds bufPeeker test helper and comprehensive test coverage for the Peek function, including success cases for all varint sizes and error cases for insufficient data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.11%. Comparing base (f3d315f) to head (89050f6).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5502      +/-   ##
==========================================
+ Coverage   84.03%   84.11%   +0.08%     
==========================================
  Files         158      158              
  Lines       16280    16291      +11     
==========================================
+ Hits        13680    13703      +23     
+ Misses       1967     1958       -9     
+ Partials      633      630       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@marten-seemann marten-seemann force-pushed the peek branch 2 times, most recently from f170959 to 045da59 Compare December 29, 2025 12:23
@marten-seemann marten-seemann changed the base branch from peek to master December 29, 2025 12:38
@marten-seemann marten-seemann marked this pull request as ready for review December 29, 2025 12:39
Peek doesn’t consume any more bytes than needed to parse the next QUIC
varint.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@marten-seemann marten-seemann merged commit 4a8af22 into master Dec 29, 2025
56 checks passed
@marten-seemann marten-seemann deleted the peek-varint branch December 29, 2025 14:33
wwqgtxx pushed a commit to MetaCubeX/quic-go that referenced this pull request Jan 3, 2026
Peek doesn’t consume any more bytes than needed to parse the next QUIC
varint.
wwqgtxx pushed a commit to MetaCubeX/quic-go that referenced this pull request Jan 11, 2026
Peek doesn’t consume any more bytes than needed to parse the next QUIC
varint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants