-
-
Notifications
You must be signed in to change notification settings - Fork 10
Add MRT record debugging and raw byte export #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Breaking change: RawMrtRecord::raw_bytes renamed to message_bytes and a new header_bytes field was added. The raw_bytes() method now returns the complete MRT record bytes (header + body) without re-encoding. Also add raw-byte helpers, Display implementations, CLI --level/--format options, and examples mrt_debug and extract_problematic_records
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #255 +/- ##
========================================
Coverage 90.50% 90.50%
========================================
Files 81 81
Lines 13006 13260 +254
========================================
+ Hits 11771 12001 +230
- Misses 1235 1259 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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 pull request adds comprehensive debugging and raw byte export capabilities for MRT records, making it easier to identify and analyze problematic data. The changes include breaking API improvements to RawMrtRecord for better clarity, new helper methods for exporting raw bytes, human-readable Display implementations for MRT types, enhanced CLI options for record-level output, and new example programs demonstrating these debugging features.
Key changes:
- Breaking change:
RawMrtRecord.raw_bytesfield renamed tomessage_bytes, with newheader_bytesfield andraw_bytes()method for complete record export - New debugging methods:
write_raw_bytes(),append_raw_bytes(),total_bytes_len()onRawMrtRecord - CLI enhancements: new
--leveland--formatoptions for granular output control (elements vs records, various formats)
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/parser/mrt/mrt_record.rs | Breaking change to RawMrtRecord struct (field rename), added raw byte export methods, comprehensive tests, and updated usage of new header parsing API |
| src/parser/mrt/mrt_header.rs | New ParsedHeader struct and parse_common_header_with_bytes() function to preserve raw header bytes alongside parsed data, with tests |
| src/models/mrt/mod.rs | Added Display implementations for CommonHeader, MrtRecord, and MrtMessage for human-readable pipe-delimited debug output, with tests |
| src/bin/main.rs | New OutputFormat and OutputLevel enums, updated CLI arguments, and refactored output logic to support record-level and multi-format output |
| examples/mrt_debug.rs | New example demonstrating debug features: JSON output, Display formatting, and raw byte export with verification |
| examples/extract_problematic_records.rs | New example for finding and exporting problematic MRT records that fail to parse |
| examples/README.md | Documentation for the two new debugging and analysis examples |
| tests/raw_iter.rs | Updated tests to use new total_bytes_len() method instead of accessing raw_bytes field directly |
| CHANGELOG.md | Comprehensive documentation of breaking changes and new features |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // Export a few records to demonstrate the functionality | ||
| let parser = BgpkitParser::new(url).unwrap(); | ||
| let output_file = "/tmp/debug_records.mrt"; |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using hardcoded /tmp/ path is not cross-platform compatible and will fail on Windows. Consider using std::env::temp_dir() or a library like tempfile to create a temporary file path that works across all platforms.
Example:
let output_file = std::env::temp_dir().join("debug_records.mrt");Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request introduces significant improvements to MRT record handling, especially for debugging and raw data export. The changes include a breaking update to the
RawMrtRecordstruct, new methods for exporting and inspecting raw MRT bytes, enhanced CLI output options, and new example programs demonstrating these features. Additionally, human-readableDisplayimplementations for key MRT types have been added to aid debugging.Breaking changes and API improvements
RawMrtRecordstruct update: Theraw_bytesfield is renamed tomessage_bytesfor clarity, and a newheader_bytesfield is added to store the raw header bytes. Theraw_bytes()method now returns the complete MRT record (header + body) without re-encoding. [1] [2]parse_common_header_with_bytesto return both the parsed header and its raw bytes, enabling exact preservation and export of original MRT records. [1] [2] [3] [4] [5]RawMrtRecordfor exporting raw bytes, calculating total length, and extensive tests for header parsing and byte preservation. [1] [2]Debugging and output enhancements
DisplayforMrtRecord,CommonHeader, andMrtMessage, allowing for concise debug output of records and messages. [1] [2] [3]--level(elemsorrecords) and--format(default,json,json-pretty,psv) options for granular and structured output, including full JSON export of records for debugging.New examples and documentation
mrt_debug.rsto demonstrate debug output and raw byte export, andextract_problematic_records.rsto find and export records that fail to parse. [1] [2]examples/README.mdto include new debugging and analysis examples.These changes greatly improve the ability to debug, analyze, and export MRT records, making it easier to identify and investigate problematic data.Breaking change: RawMrtRecord::raw_bytes renamed to message_bytes and a new header_bytes field was added. The raw_bytes() method now returns the complete MRT record bytes (header + body) without re-encoding. Also add raw-byte helpers, Display implementations, CLI --level/--format options, and examples mrt_debug and extract_problematic_records