feat(storable): implement Storable for unbounded 2-tuples [v0.6 backport]#435
Closed
lpahlavi wants to merge 1 commit intorelease/v0.6from
Closed
feat(storable): implement Storable for unbounded 2-tuples [v0.6 backport]#435lpahlavi wants to merge 1 commit intorelease/v0.6from
lpahlavi wants to merge 1 commit intorelease/v0.6from
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Backports the main-branch work from #434 to v0.6.9, implementing support for (A, B) tuple serialization/deserialization when either element is unbounded, while keeping the existing bounded 2-tuple wire format unchanged for backwards compatibility.
Changes:
- Implement unbounded
(A, B)tupleStorable::to_bytesandStorable::from_bytesusing the established size-lengths header approach (only when needed). - Add property-based and unit tests covering unbounded 2-tuples, mixed bounded/unbounded tuples, optional tuples, and
BOUND/fixed-size expectations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/storable/tuples.rs |
Replaces todo!() paths with a concrete unbounded 2-tuple wire format implementation consistent with existing tuple encoding patterns. |
src/storable/tests.rs |
Adds proptest coverage and bound assertions to validate unbounded and mixed bounded/unbounded 2-tuple behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replaces the two `todo!()` panics in the `(A, B)` `Storable` impl
(`into_bytes_inner_2` and `from_bytes`) with a working implementation
for unbounded tuples. The bounded 2-tuple wire format is unchanged.
Wire format for unbounded `(A, B)`, documented in a comment inside the
impl block mirroring the 3-tuple style:
If A is fixed-size:
<a_bytes> <b_bytes>
Otherwise:
<size_lengths (1B)> <size_a (1-4B)> <a_bytes> <b_bytes>
`size_lengths` encodes (in 2 bits) the number of bytes used to store
`size_a`, matching the encoding already used by the 3-tuple path.
`B`'s length is always inferred from the remaining bytes.
Tests mirror the 3-tuple unbounded test coverage:
- `tuple_with_two_unbounded_elements_roundtrip`
- `tuple_with_two_elements_bounded_and_unbounded_roundtrip` (with byte count)
- `optional_tuple_with_two_unbounded_elements_roundtrip`
- `optional_tuple_with_two_elements_bounded_and_unbounded_roundtrip`
- `tuple_with_two_elements_test_bound`
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5740352 to
109072f
Compare
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.
Cherry-pick of #434 onto
v0.6.9.Summary
todo!()panics in the(A, B)Storableimpl (to_bytesandfrom_bytes) with a working implementation for unbounded tuples.maincherry-pick: because v0.6 has nointo_bytesmethod, the unbounded logic is inlined directly into_bytes, matching the style of the v0.6 3-tuple implementation.Wire format for unbounded
(A, B)🤖 Generated with Claude Code