Skip to content

feat(mqtt): leveld parser#94

Merged
qzhuyan merged 8 commits intomainfrom
dev/leveld-parser
Apr 7, 2026
Merged

feat(mqtt): leveld parser#94
qzhuyan merged 8 commits intomainfrom
dev/leveld-parser

Conversation

@qzhuyan
Copy link
Copy Markdown
Collaborator

@qzhuyan qzhuyan commented Apr 6, 2026

Description

Please include a summary of the changes and which issue is fixed. Please also include relevant motivation and context.

Fixes #(issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

  • Test A
  • Test B

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Performance Impact

  • This change improves performance
  • This change has no performance impact
  • This change may have performance implications (please describe)

Security Considerations

  • This change has no security implications
  • This change has security implications (please describe)

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 6, 2026

Codecov Report

❌ Patch coverage is 91.87063% with 186 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.91%. Comparing base (722f1d9) to head (a3b9a69).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/mqtt_serde/parser/leveled.rs 89.26% 167 Missing ⚠️
src/mqtt_serde/parser/stream.rs 94.00% 19 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #94      +/-   ##
==========================================
+ Coverage   74.78%   76.91%   +2.12%     
==========================================
  Files          63       66       +3     
  Lines       15062    17049    +1987     
==========================================
+ Hits        11264    13113    +1849     
- Misses       3798     3936     +138     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

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

Adds a “leveled” MQTT parsing mode to support parsing packets at different depths (type-only, raw body, headers-only, or full), enabling consumers to trade parsing cost for throughput.

Changes:

  • Introduces parser::leveled with ParseLevel, ParsedPacket, and level-specific parse functions.
  • Extends MqttParser with parse_level configuration and a new next_parsed() API.
  • Adds ControlPacketType::from_first_byte() and MqttPacket::packet_type() helpers used by the leveled parser.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/mqtt_serde/parser/stream.rs Adds parse-level configuration and next_parsed() to the streaming parser.
src/mqtt_serde/parser/mod.rs Exposes the new leveled parser module.
src/mqtt_serde/parser/leveled.rs Implements leveled parsing (L0–L3) plus unit tests.
src/mqtt_serde/mod.rs Re-exports ParseLevel from the crate root.
src/mqtt_serde/control_packet.rs Adds helpers to extract/control packet type information.
mqtt_grpc_duality/src/bin/r-proxy.rs Removes stray whitespace in imports.

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

Comment on lines +404 to +410
ParsedPacket::HeadersParsed(HeadersParsedPacket {
packet_type: pkt_type,
flags,
mqtt_version: 4,
variable_header,
raw_payload,
}),
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

parse_headers_only() routes both MQTT v3.1 (3) and v3.1.1 (4) to parse_headers_only_v3, but the returned HeadersParsedPacket hard-codes mqtt_version: 4. This misreports the negotiated protocol version when parsing v3.1 packets. Consider passing the input mqtt_version through (or storing 3 vs 4 based on the caller) instead of always using 4.

Copilot uses AI. Check for mistakes.
Comment thread src/mqtt_serde/parser/leveled.rs Outdated
Comment thread src/mqtt_serde/parser/leveled.rs
Comment thread src/mqtt_serde/parser/leveled.rs
Comment thread src/mqtt_serde/parser/leveled.rs
Comment thread src/mqtt_serde/parser/leveled.rs
Comment thread src/mqtt_serde/parser/leveled.rs
@qzhuyan qzhuyan marked this pull request as ready for review April 7, 2026 13:32
@qzhuyan qzhuyan merged commit b464e60 into main Apr 7, 2026
28 checks passed
@qzhuyan qzhuyan deleted the dev/leveld-parser branch April 7, 2026 15:44
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.

3 participants