Repository navigation
refactor(tlv): decode and encode piece wire layouts with zerocopy structs - #119
Merged
Merged
Conversation
…ucts Replace manual byte-slice parsing and assembly across the piece and download request/response TLV types with fixed-layout zerocopy structs. Fixed-size header fields are now read and written through typed wire layouts, and decoding tolerates trailing bytes beyond the known layout instead of rejecting the message. Adds the zerocopy dependency. Signed-off-by: Gaius <gaius.qi@gmail.com>
… API Introduce a `Message` trait with `encode`/`decode` and implement it for all TLV packet types, replacing the ad-hoc `From<Bytes>`/`Into<Bytes>` conversions. Piece metadata parsing is consolidated into a shared `PieceMetadata` codec with strict length-prefixed decoding, and the `Close` packet type is removed along with its module. Also update tests, benches, and docs: drop the old proptest suite in favor of wire-format and packet-stream integration tests, add proptest roundtrips for encode/decode, add truncation checks for piece content decoding, and document the wire format in the README. Signed-off-by: Gaius <gaius.qi@gmail.com>
gaius-qi
requested review from
ClementMaH,
EvanCley,
fcgxz2003,
hyy0322,
xujihui1985 and
yyzai384
October 15, 2026 03:30
…eature/zerocopy Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
gaius-qi
enabled auto-merge (squash)
October 15, 2026 03:48
CormickKneey
approved these changes
Oct 15, 2026
hhhhsdxxxx
approved these changes
Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces significant updates to the Vortex protocol crate, focusing on clarifying and documenting the wire format, simplifying error handling, modernizing and expanding benchmarks, and making several project metadata improvements. The changes enhance the developer experience, ensure protocol interoperability, and streamline the codebase by removing unnecessary components.
Documentation and Protocol Clarification:
docs/README.mdto specify the exact wire format for all message types, including detailed tables for each packet value, field sizes, and semantics. Clarified that the wire format is stable and interoperable across releases, and updated behavioral descriptions for each tag.README.mdshowing how to encode and decode messages using the crate, and clarified benchmarking instructions to match the new benchmark structure.Benchmarking Overhaul:
benches/vortex.rsto benchmark encoding and decoding (including full packets) for all message types using a generic helper, replacing the previous approach that benchmarked only construction, serialization, and deserialization for a limited set of types.Error Handling Simplification:
Errortype insrc/error/mod.rsby removing unused variants and conversion errors, focusing on protocol-level errors only. Updated documentation for clarity.Project Metadata Updates:
Cargo.tomlto bump the version to 0.2.0, set the minimum Rust version, update the repository URL, and add thezerocopydependency for future extensibility.Codebase Cleanup:
src/tlv/close.rsfile, as the protocol now treats Close as an empty value with no special struct or logic required.Performance
Related Issue
Motivation and Context
Screenshots (if appropriate)